summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prolog/engine.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/prolog/engine.py b/prolog/engine.py
index 088948e..53307cb 100644
--- a/prolog/engine.py
+++ b/prolog/engine.py
@@ -46,8 +46,10 @@ class Term(object):
if not PL_is_list(self.ref):
raise TypeError('term is not a list')
ref = self.ref
- head, tail = Term(), Term()
- while PL_get_list(ref, head.ref, tail.ref):
+ while True:
+ head, tail = Term(), Term()
+ if not PL_get_list(ref, head.ref, tail.ref):
+ break
yield head
ref = tail.ref
@@ -165,6 +167,7 @@ class PrologEngine(object):
result = []
if PL_next_solution(qid):
+ solutions = list(solutions)
fid_solution = PL_open_foreign_frame()
for solution in solutions:
PL_unify(goal.ref, solution.ref)