Lists, for now, can be regarded as special Prolog structures that can be used to represent an ordered sequence of Prolog terms. For example, here are some legal lists:
[ice_cream, coffee, chocolate] a list with three elements (all atoms)The last example is a little difficult to decipher: the first element is happy(fred), the second is [ice_cream,chocolate], a list, and the third is [1,,3], another list.
[a, b, c, c, d, e] a list with six elements (all atoms)
[ ] a list with no elements in it (it is an atom)
[dog(fido), cat(rufus), goldfish(jimmy)] a list with three elements (all Prolog terms)
[happy(fred),[ice_cream,chocolate],[1,,3]] a list with three elements!
Note that the ``,'' used in the construction of a list is just an argument separator as in the term foo(a,b). Also note that, because order is preserved, the list [a,b,c] is not the same as [a,c,b].