next up previous contents
Next: The Occurs Check Up: Prolog Syntax Previous: (Compound) Terms as

Compound Terms and Unification


?- happy(X)=sad(jim).

---fails, because we know that it is necessary that the principal functors and their arities are the same for unification to succeed.

?- data(X,salary(10000))=data(name(fred),Y).

---succeeds, because, having matched the principal functors (and checked that the arities are the same) we recursively try to match corresponding arguments. This generates two subgoals:
X = name(fred)

salary(10000) = Y [-5pt]

which both succeed.

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