C++ & swig

This commit is contained in:
Vítor Santos Costa
2015-02-09 01:53:28 +00:00
parent a8a63a31ca
commit 88e3d637ec
15 changed files with 134 additions and 88 deletions

View File

@@ -9,14 +9,14 @@ engine = yap.YAPEngine();
def go():
while True:
s = raw_input("Prolog Query: ")
try:
q = engine.query(s)
except:
print "Oops! That was no valid number. Try again..."
q = engine.query(s)
while q.next():
vs = q.namedVars();
while vs.length() > 0:
eq = vs.car()
print eq.getArg(1).text() + " = " + eq.getArg(2).text()
vs = vs.cdr()
if vs.length() == 0:
print "yes"
else:
while vs.length() > 0:
eq = vs.car()
print eq.getArg(1).text() + " = " + eq.getArg(2).text()
vs = vs.cdr()
print "no more answers"