port of PYSWIP package.

This commit is contained in:
Vítor Santos Costa
2010-06-01 00:33:32 +01:00
parent 0645040602
commit e94104306c
27 changed files with 2502 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
from pyswip import *
p = Prolog()
assertz = Functor("assertz")
parent = Functor("parent", 2)
test1 = newModule("test1")
test2 = newModule("test2")
call(assertz(parent("john", "bob")), module=test1)
call(assertz(parent("jane", "bob")), module=test1)
call(assertz(parent("mike", "bob")), module=test2)
call(assertz(parent("gina", "bob")), module=test2)
print "knowledgebase test1"
X = Variable()
print "ok"
q = Query(parent(X, "bob"), module=test1)
print "ok"
while q.nextSolution():
print X.value
q.closeQuery()
print "knowledgebase test2"
q = Query(parent(X, "bob"), module=test2)
while q.nextSolution():
print X.value
q.closeQuery()