0

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 ]=>
Liu Weibo
  • 434
  • 5
  • 16

1 Answers1

1

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
Amadan
  • 191,408
  • 23
  • 240
  • 301