Lists are the kind of structures available to Prolog programmers for the representation of finite sequences of arbitrary terms. A list that represents the sequence of terms t1,t2,...,tn is usually denoted as [t1,t2,...,tn] . To represent the sequence that contains no terms at all, one can use the empty list , which is denoted by [] .
A list that has at least one element has a head and a tail . Consider [t1,t2,...,tn] again. The element t1 is called the head of this list. The list [t2,...,tn] , that can be obtained by removing t1 from the given one, is called the tail of this list. In particular, the tail of a single-element list, say [t] , is the empty list [] .
When the complete structure of some list is either not available, or irrelevant , the list can be denoted in a way that specifies just its having a head and a tail like this: [H|T] . For instance, unifying this list and [t1,t2,t3,...,tn] will result in instantiating H to t1 and T to [t2,t3,...,tn] , provided that H and T are both uninstantiated. One may also specify a list with some fixed number of initial elements and an arbitrary tail by writing [t1,t2,t3,...,tn |T] . In general, one can write one list in a variety of equivalent ways, e.g. the list [t1,t2,t3,t4] can be written as [t1,t2|[t3|[t4]]] , or even as [t1|[t2|[t3|[t4|[]]]]] , which, although extremely artificial, still conforms Prolog syntax.
Consult Strawberry Prolog Specials for some implementation-specific
details on lists.