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

Compound Terms and Unification

Consider

 
?- happy(X)=sad(jim).
 [-5pt]

---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).
 [-5pt]

---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