In Petite Chez Scheme (threaded) . I defined two lists named myq and myqq.
(define make-queue
(lambda ()
(let ((end (cons 'ignored '())))
(cons end end))))
(define myqq (make-queue))
(define myq '((ignored) ignored))
;this shows myq and myqq are equal
(display (equal? myqq myq))
(newline)
;test myqq
(display myqq)
(newline)
(set-car! (cdr myqq) 'b)
(display myqq)
(newline)
;test myq
(display myq)
(newline)
(set-car! (cdr myq) 'b)
(display myq)
(newline)
this is the result:
#t
((ignored) ignored)
((b) b)
((ignored) ignored)
((ignored) b)
My question is: as the
(display (equal? myqq myq))
shows myq and myqq are equal. Why do the same commands:
(set-car! (cdr myqq) 'b)
(set-car! (cdr myq) 'b)
lead to a different result?
Plus, I don't know why (set-car! (cdr myqq) 'b)
results in ((b) b)
.I think it should result in ((ignored) b)
, because we never change the car of myqq!