| tree | tree to flatten |
|---|
(flatten '(a (b ((c) d . e)))) => (a b c d e)
(define (flatten x)
(letrec
((f (lambda (x r)
(cond ((null? x) r)
((pair? x)
(f (car x)
(f (cdr x) r)))
(else (cons x r))))))
(f x '())))