I was preparing for a test and I noticed this question:
Define an object x so that (eq? (car x) (cdr x)) returns #t
I initially thought that it would be pretty simple. cdr x
is a list and car x
is a single element, so my guess would've been make the first element in x be a list equal to the tail of x. So I came up with
(define x (list (list 1) 1))
Calling car x
in DrRacket results in (list 1)
and so does cdr x
, but when I try to call (eq? (car x) (cdr x))
the result is #f.
What exactly am I missing? Also what would the correct answer be?