next up previous contents
Next: A Recursive Program Up: Lists Previous: The Empty List

Some Possible Matches

We now illustrate how two lists unify and in what circumstances two lists fail to unify.

 
1. 		  [b,a,d]=[d,a,b] 		     fails ---as the order matters

2. [X]=[b,a,d] fails ---the two lists are of different lengths

3. [XY]=[he,is,a,cat] succeeds with

X=he, Y=[is,a,cat]

4. [X,YZ]=[a,b,c,d] succeeds with

X=a, Y=b, Z=[c,d]

5. [XY]=[] fails ---the empty list

can't be deconstructed

6. [XY]=[[a,[b,c]],d] succeeds with

X=[a,[b,c]], Y=[d]

7. [XY]=[a] succeeds with X=a, Y=[]

 



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