This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/swig/python/demo.py

34 lines
709 B
Python
Raw Normal View History

2014-06-04 22:07:37 +01:00
# python commands
import sys
import yap
2015-04-13 13:28:17 +01:00
#
# initialize engine
2014-06-04 22:07:37 +01:00
engine = yap.YAPEngine();
# engine = yap.YAPEngine(yap.YAPParams());
2015-04-13 13:28:17 +01:00
def query( s ):
q = engine.query(s)
while q.next():
vs = q.namedVars()
if vs.length() == 0:
print( "yes" )
return
else:
while vs.length() > 0:
eq = vs.car()
print( eq.getArg(1).text() + " = " + eq.getArg(2).text() )
vs = vs.cdr()
s = raw_input("next: ?")
if s.find(';') != 0 :
return
print( "no more answers" )
return
def live():
loop = True
while loop:
s = raw_input("?- ")
query( s )