1.
|

(define x
(let ((a '(9)))
(let ((b (cons a a)))
(cons b b)))
x => (((9) 9) (9) 9)
|
(set-cdr! (car x) '(8))
; after this mutation:
x => (((9) 8) (9) 8) |
2.
|
(define x
(let ((w '(a b c)))
(cons (list w)
(cons nil (cddr w)))))
x => (((a b c)) () c)
or (((a b c)) #f c)
|
(set-car! (cddr x) (caaar x))
; after this mutation:
x => (((a b a)) () a)
or (((a b a)) #f a)
|
3.
|

(define x
(let ((k '(x)))
(let ((m (list k k)))
(cons m (cdr m)))))
x => (((x) (x)) (x))
|
(set-cdr! (first x) (second x))
; after this mutation:
x => (((x) x) (x)) |
4.
|
(define x
(let ((y (list 1 2 3)))
(set-car! y y)
(set-car! (cdr y) y)
(set-car! (cddr y) y)
y))
x => ((((((((((((((((... unprintable
|
(set! x (cdadr x)
; after this mutation:
x => still unprintable
|
5.
|
(define x
(let ((z (list 3 2 1)))
(list z (cdr z) (cddr z))))
x => ((3 2 1) (2 1) (1))
|
(set-car! (cdr (second x)) 4)
; after this mutation:
x => ((3 2 4) (2 4) (4))
|
6.
|
(define x
(let ((c (cons nil nil)))
(let ((d (cons c c)))
(set-car! c d)
(set-cdr! c d)
c)))
x => ((((((((((((((((... unprintable
|
(set-car! (cdr x) nil)
(set-cdr! (car x) nil)
; after this mutation:
x => ((()) ())
or ((#f) #f)
|