Reputation: 10777
I wonder why the following piece of code gives the #f output:
=> (define a (cons 3 '()))
=> (define a (cons 3 '()))
=> (eq? a b)
;Value: #f
When comparing the lists with eq?, do we look at whether all the values and their order is same, or do we look whether two lists are the same list? Can somebody explain it?
Thanks
Upvotes: 1
Views: 99
Reputation: 70135
The function eq?
looks at whether the 'two lists are the same list'; whereas, equal?
looks at 'whether all the values and their order is the same'. In C
, think eq?
is ==
but equal?
is while (l1 && l2 && equal (l1.item, l2.item) ...
Upvotes: 2