Isn't it supposed to be (a b c d) ??
When I try it on Racket it gives me () .
Isn't it supposed to be (a b c d) ??
When I try it on Racket it gives me () .
'((a b c d))
is a list, containing only one element, that is the four-element list (a b c d)
. So if you get the car
of it, you obtain as result (a b c d)
, while the cdr
produces correctly the empty list ()
.
How would you create such a list using cons
?
(cons (cons 'a (cons 'b (cons 'c (cons 'd '()))))
'())
or
(cons '(a b c d) '())
cdr
returns the second element of the given pair, so it returns '()
.