This module implements randomized version of aggregates predicates.
?- random_findall(4, X, between(1,10000,X), Xs). Xs = [6659,7135,7871,9864] ? yes
?- random_findall(4, X, member(X, [the,sequel,will,not,happen]), Xs). Xs = [the,sequel,will,happen] ? yes
This predicate implements the reservoir sampling algorithm. It needs to evaluate all solutions to Goal but only need to keeps K of those solutions in memory simultaneously.
Obtains a list Ys of length K of random solutions uniformly distributed from X for all solutions to Goal. Fails if there are less than K solutions.