interface design

This commit is contained in:
Vitor Santos Costa 2016-12-16 03:38:40 -06:00
parent a4bb9f6e0e
commit 66bc426b09

View File

@ -161,20 +161,23 @@ class YAPInteractiveShell:
# print('{0}'.format(f.getvalue())) # print('{0}'.format(f.getvalue()))
# Execute the user code # Execute the user code
if run: if run:
myvs = self.q.namedVarsCopy() # this new vs should contain bindings to vars
if myvs: vs= self.q.namedVars()
#numbervars
i=0 i=0
for peq in myvs: # iteraw
name = peq[0] for eq in vs:
bind = peq[1] name = eq[0]
if bind.isVar(): # this is tricky, we're going to bind the variables in the term so thay we can
var = yap.YAPAtom('$VAR') # output X=Y. The Python way is to use dictionares.
f = yap.YAPFunctor(var, 1) #Instead, we use the T function to tranform the Python term back to Prolog
bind.unify(yap.YAPApplTerm(f, (name))) binding = yap.T(eq[1])
else: if binding.isVar():
i = bind.numberVars(i, True) binding.unify(name)
print(name.text() + " = " + bind.text())
else: else:
i = binding.numberVars(i, True)
print(name + " = " + binding.text())
#ok, that was Prolog code
print("yes") print("yes")
if self.q.deterministic(): if self.q.deterministic():
self.closeq() self.closeq()