【SICP练习】60 练习2.30
练习2.30
如果这道题感觉有点难度的话,可以回过头来看看75页定义的两个scale-tree。我的定义如下:
(define (square-tree tree)
(cond ((null? tree) ‘())
((not (pair? tree)) (square tree))
(else (cons (square-tree (car tree))
(square-tree (cdrtree))))))
(define (square-tree tree)
(map (lambda (sub-tree)
(if (pair? sub-tree)
(square-tree sub-tree)
(square sub-tree)))
tree))
版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。