This traverses the entire tree applying a map function to the value and stuffing back into a tree.
(define (tree-map f t)
(if (null? t)
()
(if (null? (cdr t))
()
(append (append (tree-map f (car t))
(list (f (cadr t))))
(tree-map f (caddr t))))
))
attempts to solve technical problems
(define (tree-map f t)
(if (null? t)
()
(if (null? (cdr t))
()
(append (append (tree-map f (car t))
(list (f (cadr t))))
(tree-map f (caddr t))))
))
No comments:
Post a Comment