10 Mar 2005
CS 3243 - FOL and Prolog
44
Lists
lThe first element of a list can be separated from the tail
lusing operator |
l
lExample:
l
lMatch the list [tom,dick,harry,fred] to
l
l[X|Y]          then X = tom and Y = [dick,harry,fred]
l[X,Y|Z]       then X = tom, Y = dick, and Z = [harry,fred]
l[V,W,X,Y,Z|U] will not match
l[tom,X|[harry,fred]] gives X = dick
l