Yield Prolog 1.0.3

Embed Prolog in your code
Yield Prolog is a software that lets you embed Prolog programs directly in Python, C# or JavaScript by using the yield keyword. For example, here is the classic "uncle" predicate in Prolog:

uncle(Person, Uncle) :-
 parent(Person, Parent),
 brother(Parent, Uncle).


(This says that a person has an uncle if the person has a parent and that parent has a brother.) And here it is in Yield Prolog:

Python


def uncle(Person, Uncle):
 Parent = Variable()
 for l1 in parent(Person, Parent):
 for l2 in brother(Parent, Uncle):
 yield False


C#

IEnumerable< bool > uncle(object Person, object Uncle) {
 Variable Parent = new Variable();
 foreach (bool l1 in parent(Person, Parent)) {
 foreach (bool l2 in brother(Parent, Uncle))
 yield return false;
 }
}


JavaScript

function uncle(Person, Uncle) {
 var Parent = new Variable();
 for each (var l1 in parent(Person, Parent)) {
 for each (var l2 in brother(Parent, Uncle))
 yield false;
 }
}


As you can see, the flow of the code in Yield Prolog is similar to Prolog. The Tutorial explains how these examples work, without expecting you to know Prolog. And the benchmarks show that Yield Prolog in C# can be faster than efficient Prolog systems like Yap Prolog and XSB.

Yield Prolog is made possible by the yield keyword, which automatically creates iterators that you can nest, combined with Yield Prolog's Variable class which can unify a variable with other values (just like in Prolog). There is no "API" standing between your code and Yield Prolog, because you just use the yield keyword to make "iterator functions" wherever you need them. Yield Prolog is part of your code, which can mix Prolog-style predicates directly with ordinary arrays, file I/O, GUI calls and all your own classes. Because it lets you mix these, Yield Prolog unifies the declarative and procedural programming models.

last updated on:
November 9th, 2008, 2:19 GMT
price:
FREE!
homepage:
yieldprolog.sourceforge.net
license type:
BSD License 
developed by:
Jeff Thompson
category:
ROOT \ Programming \ Interpreters
Yield Prolog
Download Button

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT