内容 2.2 Hierarchical Data and the Closure Property · 106
练习 自检推理
Exercise 2.28: Write a procedure fringe
that takes as argument a tree (represented as a list) and returns a list whose
elements are all the leaves of the tree arranged in left-to-right order. For
example,
(define x
(list (list 1 2) (list 3 4)))
(fringe x)
(1 2 3 4)
(fringe (list x x))
(1 2 3 4 1 2 3 4)
练习 2.28:写一个过程 fringe,它以一棵树(用表表示)为参数,返回一个表,其元素是该树所有的叶子,按从左到右的顺序排列。例如,
(define x
(list (list 1 2) (list 3 4)))
(fringe x)
(1 2 3 4)
(fringe (list x x))
(1 2 3 4 1 2 3 4)
SICP source code scheme
(define x
(list (list 1 2) (list 3 4)))
(fringe x)
(1 2 3 4)
(fringe (list x x))
(1 2 3 4 1 2 3 4) 我的笔记 自动保存