The aggregate predicates take a set of solutions and compute an aggregate on it. The predicate accumulate/3 aggregates the solution that is produced by findall/3. The predicate aggregate/3 respectively sys_collect/3 aggregates the solutions that are produced by bagof/3 respectively sys_heapof/3. The current implementation is not yet optimal, since the solution lists are always materialized.Examples:
Y = 4,
R = (5,1) ;
Y = 1,
R = (5,2)
The following aggregate predicates are provided:
- count: The result is the number of solutions.
- sum(X): The result is the sum of the X values.
- min(X): The result is the minimum of the X values.
- max(X): The result is the maximum of the X values.
- bag(X): The result is the list of the X values.
- nodup(X): The result is the list of the distinct X values.
- set(X): The result is the list of the sorted X values.
- (A,B): The result is the pairing of the aggregate A and B.