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 () .
Martin Půda
On
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 '().
Copyright © 2021 Jogjafile Inc.
'((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 thecarof it, you obtain as result(a b c d), while thecdrproduces correctly the empty list().