Skip to content

Instantly share code, notes, and snippets.

@emasaka
Created August 24, 2010 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emasaka/547346 to your computer and use it in GitHub Desktop.
Save emasaka/547346 to your computer and use it in GitHub Desktop.
(define (traverse-tree tree func)
(if (pair? tree)
(begin
(traverse-tree (car tree) func)
(traverse-tree (cdr tree) func) )
(or (null? tree) (func tree)) ))
(define sample-list '((3 (5 (7)) 11)))
(traverse-tree sample-list print)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment