;without using any higher order procedures
(define (square-tree tree)
(cond
((null? tree) '())
((list? (car tree))
(append (list (square-tree (car tree)))
(square-tree (cdr tree))))
(else
(cons (square (car tree))
(square-tree (cdr tree))))))
;using higher order procedures
(define (square-tree tree)
(map
(lambda (x)
(if (pair? x)
(square-tree x) (square x))) tree))
Sunday, June 7, 2009
Ex-2.30
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment