bagof/3

Returns unsorted sets of terms in solutions of a given goal

bagof(Term,Goal,List) -(?,i,?)

?Term <term>

+Goal <goal>

?List <variable> or <list>

Compatibility: LPA Win-Prolog, Swindon Prolog, most other prologs.

Remarks: This predicate returns unsorted sets of solutions that would normally be obtainable only by failing and backtracking through a query. It succeeds if List can be unified to a non-empty list of instances of Term such that Goal is true. The Term may be any Prolog term, and Goal may be any Prolog goal.

See Also:

findall/3

setof/3