bagof/4

bagof( T,+ G,- L)* is iso

For each set of possible instances of the free variables occurring in G but not in T, generates the list L of the instances of T satisfying G. Again, assuming the same clauses as in the examples above, the reply to the query


 ?- bagof(X,a(X,Y),L).

 X = _32
 Y = 1
 L = [2,1];
 X = _32
 Y = 2
 L = [2];
 no

% And this is bagof//33

% Either we have excess of variables % and we need to find the solutions for each instantiation % of these variables