Hi all,
I am confused as to how car
and cdr
work on lists. Here is an example of what I have tried:
(define sample (read))
(display sample)
(display (car sample))
(display (cdr sample))
(display (car (cadr sample)))
(display (cdr (cdr sample)))
On entering the value '(A B C D E F)
, here is what I get:
'(a b c d e f)
quote
((a b c d e f))
a
()
I am not able to understand that how quote
can be the car
of sample
. Also, why does (cdr sample)
output ((a b c d e f))
?
Language: DrScheme - R5RS - Scheme