@Var ^ +callable_term  [ISO]

The caret operator can only be used with the bagof/3, findall/3 and setof/3 predicates, it is used to indicate which variables are cleared in the Goal expression before finding the next solution. It is defined as an xfy infix operator with precedence 200.

If the 'Goal' expression contains any ^ operators then it must be rightmost goal of the expression. For example: the expression 'X ^ goal(Q)' is correct and 'goal(Q) ^ X' is not correct.

see also: bagof/3 findall/3 setof/3 setof_reverse/3

Assume the database contains the user-defined predicates:

Examples
bagof(Child, age(Child,Age), List). Age = 7, List = [peter]
Age = 5, List = [ann, tom]
Age = 8, List = [pat]
bagof(Child, Age ^ age(Child, Age), List). List = [peter, ann, pat, tom]

 

 

info@trinc-prolog.com