SICP Exercise 3.20

Exercise 3.20.  Draw environment diagrams to illustrate the evaluation of the sequence of expressions

(define x (cons 1 2))
(define z (cons x x))
(set-car! (cdr z) 17)
(car x)
17


using the procedural implementation of pairs given above. (Compare exercise 3.11.)

Solution:

The attached pictures show the progression of the environment structure as the sequence of interactions happens as specified in this exercise.

The github links are:

Page 1
Page 2
Page 3
Page 4
Page 5

The slides to the same diagrams are here








Comments

Popular posts from this blog

SICP Exercise 4.9 do for while until

SICP Exercise 3.56 merge streams

SICP Exercise 4.14 map as compound vs. primitive type