Reputation: 466
I am working on exercise 2.57 and I have such a problem what's the different between '(a b (c)) and (list 'a 'b (list 'c)) since they look exactly the same in the scheme interpreter?
1 ]=> (eq? '(a b (c)) (list 'a 'b (list 'c)))
;Value: #f
1 ]=> '(a b (c))
;Value 2: (a b (c))
1 ]=> (list 'a 'b (list 'c))
;Value 3: (a b (c))
1 ]=>
Upvotes: 0
Views: 126
Reputation: 198446
Hint: what is (eq? (list 1) (list 1))
?
eq?
only tests object identity. Two separately constructed lists are not the same list, even if their contents are the same. Use equal?
for value equality:
(equal? '(a b (c)) (list 'a 'b (list 'c)))
; => #t
Upvotes: 1