`^/2`

`+X` `^`

`+P`

Equivalent to “there exists an `X` such that `P` is
true”, thus `X` is normally an unbound variable. The use of the
explicit existential quantifier outside `setof/3`

and `bagof/3`

is superfluous.

`X`*term*`:P`*callable*, must be nonvar

Equivalent to simply calling `P`.

Depends on `P`.

Call errors (see ref-sem-exc).

Using `bagof/3`

without and with the existential quantifier:

| ?-bagof(X, foo(X,Y), L).X = _3342, Y = 2, L = [1,1];X = _3342, Y = 3, L = [2];no | ?-bagof(X, Y^foo(X,Y), L).X = _3342, Y = _3361, L = [1,1,2];no

`setof/3`

, `bagof/3`

, ref-all.

Send feedback on this subject.