chickadee » anaphora » tree-recurser

tree-recurser recurser baseprocedure

generates a procedure which traverses on the cars and the cdrs of its only tree argument.

(define tcopy
  (tree-recurser (lambda (tree left right)
                   (cons (left) (or (right) '())))
                 identity))
(tcopy '(1 (2 (3 4) 5) 6)) ; -> '(1 (2 (3 4) 5) 6)