CONS constructs a pair. A pair of two things. It is written as (firstthing . secondthing)
.
If the second thing is an empty list, it is written as (firstthing)
. It is the same as (firstthing . ())
.
Since cons
constructs a cons, the result of (cons 1 2)
is (1 . 2)
.
(cadr (cons 1 2))
is an error. It is (car (cdr (cons 1 2))
. (cdr (cons 1 2)
is 2
. Now (car 2)
is wrong. You can't take the car of 2
. 2
is a number, not a cons.
If you want to create a list, which is made of cons cells or the empty list, then use the function list
.