I have had a few bad experiences with the scoping rules in the default aggregation meta-predicates, and thought that it might be handy to use yall to use aggregation instead. i.e. the aggregator template is just the single argument to a predicate which acts as a generator.
:- meta_predicate sol_set(1,?).
sol_set(Predicate,Result) :-
findall(Template,
apply(Predicate, [Template]),
Templates),
sort(Templates, Result).
:- meta_predicate sol_bag(1,?).
sol_bag(Predicate,Result) :-
findall(Template,
apply(Predicate, [Template]),
Result).
However, I also noticed that you can capture the formal parameter list from yall! I had never considered this before for some reason.
I wonder is there any way that this can be overcome with goal-expansion magic?
And if not, I wonder if there is a way to have a fairly conservative expansion of prolog that includes “lambdas” of some form.