Previous topic  Top  Next topic  Print this Topic



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



Internally a list is represented by recursively nesting the binary function symbol $l ( <obl:intern:l>). Its first argument represents the first element of the list and its second argument represents the rest of the list (i.e. head and tail in Prolog-speak, or car and cdr in Lisp-speak).

The example list presented above has the internal represenation:


$l(a, $l(b, $l(c, $l(d, $l(e, [])))))


Note the empty list to represent the end of the list. Due to the canonical mapping even open lists with no fixed length can be represented, e.g.


[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 lists firsts element.