协助描绘树或框指针结构
Assistance to portray the tree or box-pointer strucure
我正在研究 SICP 的 Exercise 2.24:
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).
并绘制框和指针为
(1 (2 (3 4))) ((2 (3 4)))
[*]---------------> [*]
| |
| |
v v (2 (3 4)) ((3 4))
1 [*]---------------> [*]
| |
| |
v v (3 4) (4)
2 [*]---------------> [*]---------------> '()
| |
| |
v v
和树
(1 (2 (3 4)))
*
/ \
/ \ (2 (3 4))
1 *
/ \
/ \ (3 4)
2 *
/ \
/ \
3 4
是否有任何解决方案可以描绘这种树或框指针结构?
一开始可能会很有帮助,因为立即想象结构并不容易。
当你使用 Racket 时,你可能需要 sdraw。例如,您可以通过 raco pkg install sdraw
.
我正在研究 SICP 的 Exercise 2.24:
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).
并绘制框和指针为
(1 (2 (3 4))) ((2 (3 4)))
[*]---------------> [*]
| |
| |
v v (2 (3 4)) ((3 4))
1 [*]---------------> [*]
| |
| |
v v (3 4) (4)
2 [*]---------------> [*]---------------> '()
| |
| |
v v
和树
(1 (2 (3 4)))
*
/ \
/ \ (2 (3 4))
1 *
/ \
/ \ (3 4)
2 *
/ \
/ \
3 4
是否有任何解决方案可以描绘这种树或框指针结构?
一开始可能会很有帮助,因为立即想象结构并不容易。
当你使用 Racket 时,你可能需要 sdraw。例如,您可以通过 raco pkg install sdraw
.