next up previous contents
Next: Stage 3 Up: Powerful Features ---Finding Previous: Stage 1

Stage 2

Now suppose we only want to gather the first element of the pairs.

 
?- setof(X,Y^knows(X,Y),Z).

Z = [jim, alf] [-5pt]

Wait a minute ... what is that Y^ bit? You have to existentially quantify any variables in which you are not interested if you are to get the set of all solutions and a reasonably clean semantics.

You have to read this as ``find the set Z consisting of all values of X for which there exists a value Y for which knows(X,Y)''. The Y^ is interpreted as ``there exists a Y'' and is vital.



Paul Brna
Mon May 24 20:14:48 BST 1999