Cons Cells
Because cons is weird.
Terms
cons
means "construct"car
: address registercdr
: document register
Examples
Recursively construct a list in order:
(cons 1 (cons 2 (cons 3 nil)))
1 | 2 | 3 |
Cons a list with another list:
(cons '(1 2) '(3 4))
(1 2) | 3 | 4 |
Cons two cons cells:
(cons (cons 1 2) (cons 3 4))
#+RESULTS:
((1 . 2) 3 . 4)
(cons (cons 1 (cons 2 3)) 4)
#+RESULTS:
((1 2 . 3) . 4)
(cons (cons 1 2) (cons (cons 3 4) nil))
#+RESULTS:
((1 . 2) (3 . 4))
(cons 1 (cons 2 (cons 3 4)))
#+RESULTS:
(1 2 3 . 4)