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 2.56 differentiation rule

SICP Exercise 1.28 (Miller-Rabin Test)

SICP Exercise 4.18 a alternative strategy for interpreting internal definitions