The result of make-queue
is a structure consisting of two cons cells, not three:
- One cons cell contains
ignored
and()
incar
andcdr
respectively. - The other cons cell contains a link to the first cons cell in both its
car
and itscdr
.
When you do (set-car! (cdr myqq) 'b)
, you're changing the car
of the first cons cell (because this is what is referenced in (cdr myqq)
) from ignored
to b
.
equal?
recursively checks pairs and similar structures, ultimately applying eqv?
to the primitive values (in your case symbols). It doesn't count the fact that there is structural sharing between different components in myqq
, and this isn't the case for myq
, as a relevant difference.
equal?
isn't the final word on equality, it's just one particular (and often useful) sense in which two structures can be equal. You can use other comparison functions to see that there's a difference between the two structures, e.g.:
>>> (eq? (car myqq) (cdr myqq))
#t
>>> (eq? (car myq) (cdr myq))
#f