User9193
User9193

Reputation: 57

What defines structural equality?

In terms of structural equality,

Why would (equal? (list 'a 'b)) evaluate to true but (equal? (list 2 'b) '(2 'b)) evaulates to false?

Upvotes: 0

Views: 282

Answers (1)

sepp2k
sepp2k

Reputation: 370202

'(2 'b) is equivalent to (list 2 (list 'quote 'b)) - a list whose first element is a number and whose second element is another list.

It does not compare equal to (list 2 'b) because (list 2 'b)'s second element is a symbol and symbols are not considered equal to lists.

Upvotes: 1

Related Questions