call(Folder,V0,V1)
. This predicate provides behaviour similar to
aggregate_all/3-4, but operates in constant space and allows for
custom aggregation (Folder) operators. The example below uses plus/3
to realise aggregate_all(sum(X), between(1,10,X), Sum)
.
?- foldall(plus(X), between(1,10,X), 0, Sum). Sum = 55
The implementation uses nb_setarg/3 for non-backtrackable state updates.