Exercise 1.4.7

Lists

A list is either the empty list, or a chain of Cons-Cells ending with the empty list.

* (listp nil)
T

* (listp (cons 5 nil))
T

If you cons something onto the empty list, you get the list of that thing.

* (cons 5 nil)
(5)

We can exploit the Cons-Cells' ability to contain heterogenous data in order to represent linked lists or trees.

* (cons 3 (cons 2 (cons 1 nil)))
(3 2 1)

results matching ""

    No results matching ""