use acyclic iteration when projecting onto query vars

This commit is contained in:
Mark Thom
2019-02-22 17:48:49 -07:00
parent f41b5f465e
commit 6ba47b6b08
6 changed files with 30 additions and 14 deletions

View File

@@ -361,10 +361,14 @@ throw(Ball) :- '$set_ball'(Ball), '$unwind_stack'.
'$truncate_if_no_lh_growth'(LhOffset),
'$get_lh_from_offset'(LhOffset, Solutions).
truncate_lh_to(LhLength) :- '$truncate_lh_to'(LhLength).
findall(Template, Goal, Solutions) :-
'$skip_max_list'(_, -1, Solutions, R),
( nonvar(R), R \== [], throw(error(type_error(list, Solutions), findall/3))
; true
),
'$lh_length'(LhLength),
'$call_with_default_policy'('$iterate_find_all'(Template, Goal, Solutions, LhLength)).
'$call_with_default_policy'(catch('$iterate_find_all'(Template, Goal, Solutions, LhLength),
Error,
( truncate_lh_to(LhLength), throw(Error) ))).