Previous topic  Top  Next topic  Print this Topic
 

Lists

 

Lists are a special kind of term. In ObjectLogic, lists of terms can be represented as in Prolog. A list containing the constants a to e looks like this:

[a, b, c, d, e]

Due to the canonical mapping, even open lists with no fixed length can be represented, for example:

[a, b, c, d | Tail]

The variable Tail represents the currently not bound list, following the fourth element of this list. Note the "|"-symbol after d. This symbol separates the remainder of the list of the list's first element. When replacing "|" with "," (yielding ) represents a list of exactly five elements, whose first elements are fixed and whose fifth element is not yet bound.

In this case Tail may even also represent a list, but then the two example lists would still be different as ,in this case, the list Tail is the fifth element not the cdr. Assume Tail to be [X, Y]. Then the two lists would be

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

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