|
Both examples make sense, and they do the same thing.
But the tree example isn't quite in the spirit of general trees. In that spirit, it makes more sense to suppose that all leaves must be numbers, instead of treating >((reduce-tree + (lambda (x) x)) (cons (cons 1 2) (cons 3 4))) 10Of course, when you use reduce-tree to reimplement nested-reduce, you need precisely the sort of conditional treatment of nil in Mr. Kettler's example, since now your code must deal with tree encodings of lists, rather than trees for their own sakes.
Mike O'D. |
to: