Syntactically, a list is denoted by square brackets with the terms separated by commas. This gives us an alternative way of representing the locations of things. Rather than having separate location predicates for each thing, we can have one location predicate per container, with a list of things in the container. It is also referred to as nil . It can describe the lack of contents of a place or thing.
Unification works on lists just as it works on other data structures.
This last example is an impractical method of getting at list elements, since the patterns won't unify unless both lists have the same number of elements. For lists to be useful, there must be easy ways to access, add, and delete list elements. Moreover, we should not have to concern ourselves about the number of list items, or their order. Two Prolog features enable us to accomplish this easy access. One is a special notation that allows reference to the first element of a list and the list of remaining elements, and the other is recursion.