This commit is contained in:
Vitor Santos Costa
2019-03-18 14:47:29 +00:00
parent e8d9e71a4e
commit 70a43ece1d
14 changed files with 105 additions and 83 deletions

View File

@@ -79,16 +79,14 @@ python_query( Caller, String, Bindings ) :-
output(Caller, Bindings).
output( Caller, Bindings ) :-
fail,
Answer := {},
% start_low_level_trace,
Caller.answer := {},
/* % start_low_level_trace,
foldl(ground_dict(answer), Bindings, [], Ts),
term_variables( Ts, Hidden),
foldl(bv, Hidden , 0, _),
maplist(into_dict(Answer),Ts),
Caller.answer := Answer,
fail.
*/ maplist(into_dict(answer),Bindings),
:= print(answer)},
Caller.answer := answer.
output( _, Bindings ) :-
write_query_answer( Bindings ),

View File

@@ -1,4 +1,5 @@
import readline
import copy
from yap4py.yap import *
from yap4py.systuples import *
from os.path import join, dirname
@@ -76,11 +77,10 @@ class Query (YAPQuery):
return self.port == "fail" or self.port == "exit"
def __next__(self):
self.answer = {}
if self.port == "fail" or self.port == "exit":
raise StopIteration()
if self.next():
return self.answer
return copy.deepcopy(self.answer)
raise StopIteration()
def name( name, arity):

View File

@@ -333,9 +333,9 @@ The following magic functions are currently available:
"""
default_banner_parts = ["Python %s\n"%sys.version.split("\n")[0],
default_banner_parts = ["YAP %s\n"%sys.version.split("\n")[0],
"Type 'copyright', 'credits' or 'license' for more information\n" ,
"yap_ipython {version} -- An enhanced Interactive Python. Type '?' for help.\n".format(version=release.version),
"yap_ipython {version} -- An enhanced Interactive Prolog for Jupyter. Type '?' for help.\n".format(version=release.version),
]
default_banner = ''.join(default_banner_parts)

View File

@@ -563,7 +563,8 @@ class YAPRun(InteractiveShell):
self.answers = []
for answer in self.query:
print( answer )
self.answers += [copy.deepcopy(answer)]
self.answers += [answer]
print( self.answers)
self.iterations += 1
self.os = None