func
func copied to clipboard
functions inside forall, foreach, findall, bagof, etc.
Expanding a function inside the goal argument of these predicates should keep the entire expansion inside the predicate. Currently it moves the expansion outside the predicate.
A concrete example of the problem:
$ cat expand.pl
:- use_module(library(func)).
nmain :-
bagof(x,between(1,succ(2,~),_),Xs),
writeln(Xs).
$ swipl -q -s expand.pl
1 ?- listing(main).
main :-
succ(2, A),
bagof(x, between(1, A, _), B),
writeln(B).
true.
The listing should have been as follows:
main :-
bagof(x, (succ(2,A),between(1, A, _)), B),
writeln(B).