From da315b26882337fc8b492fb17a4452bca6be7b6a Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 5 Apr 2016 08:18:50 +0100 Subject: [PATCH] missing --- packages/swig/python/yapy.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 packages/swig/python/yapy.py diff --git a/packages/swig/python/yapy.py b/packages/swig/python/yapy.py new file mode 100644 index 000000000..829a38aa6 --- /dev/null +++ b/packages/swig/python/yapy.py @@ -0,0 +1,33 @@ +# python commands + +import sys +import yap + +# +# initialize engine +engine = yap.YAPEngine(); +# engine = yap.YAPEngine(yap.YAPParams()); + +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 )