bagof/3

Synopsis

bagof(+Template, +*Generator, *Set)

Like setof/3 except that the list (or alternative lists) returned will not be ordered, and may contain duplicates. This relaxation saves time and space in execution.

Arguments


Template term

Generator callable [MOD]
a goal to be proved as if by call/1.
Set list of term
non-empty set

Examples

See findall/3 for examples that illustrate the differences among findall/3, setof/3, and bagof/3.

Exceptions

As for call/1, and additionally:


resource_error
Template contains too many free variables.

See Also

findall/3, setof/3, ^/2 ref-all