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,21 +161,24 @@ 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()
i = 0 #numbervars
for peq in myvs: i=0
name = peq[0] # iteraw
bind = peq[1] for eq in vs:
if bind.isVar(): name = eq[0]
var = yap.YAPAtom('$VAR') # this is tricky, we're going to bind the variables in the term so thay we can
f = yap.YAPFunctor(var, 1) # output X=Y. The Python way is to use dictionares.
bind.unify(yap.YAPApplTerm(f, (name))) #Instead, we use the T function to tranform the Python term back to Prolog
else: binding = yap.T(eq[1])
i = bind.numberVars(i, True) if binding.isVar():
print(name.text() + " = " + bind.text()) binding.unify(name)
else: else:
print("yes") i = binding.numberVars(i, True)
print(name + " = " + binding.text())
#ok, that was Prolog code
print("yes")
if self.q.deterministic(): if self.q.deterministic():
self.closeq() self.closeq()
else: else: