I am working on Exercise 2.24 of SICP:
Exercise 2.24. Suppose we evaluate the expression (list 1 (list 2 (list 3 4))). Give the result printed by the interpreter, the corresponding box-and-pointer structure, and the interpretation of this as a tree (as in figure 2.6).
And draw box-and-pointer as
(1 (2 (3 4))) ((2 (3 4)))
[*]---------------> [*]
| |
| |
v v (2 (3 4)) ((3 4))
1 [*]---------------> [*]
| |
| |
v v (3 4) (4)
2 [*]---------------> [*]---------------> '()
| |
| |
v v
and tree
(1 (2 (3 4)))
*
/ \
/ \ (2 (3 4))
1 *
/ \
/ \ (3 4)
2 *
/ \
/ \
3 4
Are there any solutions which could portray such tree or box-pointer structures?
It might be very helpful in the beginning since it's not that easy to imagine the structures instantly.
As you are using Racket, you probably want sdraw. You can get this by, for instance, raco pkg install sdraw
.