Say I want to find sum of all solutions to a predicate, I just can use
findall(L, find(L), Sols),
and just sum members of Sols.
But
I think you will need to manually implement the uniqueness condition that is implied in findall, i.e., you will need to aggregate solutions and for each new one check that it hasn't yet been picked before.
Here is an example of how this can work:
%% an example predicate with infinite solutions
find(0).
find(X) :- find(X1), X is X1+1.
%% myfindall(+Num) holds when there are at least Num different solutions for find
myfindall(Num) :-
length(L, Num),
mfa_aux(L, [], All),
%% now do something with All, e.g., sum it.
writeln(All).
mfa_aux([], All, All).
mfa_aux([H|T], All, Rtv) :-
find(H),
not(member(H, All)), !,
mfa_aux(T, [H|All], Rtv).
%% Test
%% ?- myfindall(10).