Skip to content

Instantly share code, notes, and snippets.

@kosugi
Created July 1, 2012 04:13
Show Gist options
  • Select an option

  • Save kosugi/3026796 to your computer and use it in GitHub Desktop.

Select an option

Save kosugi/3026796 to your computer and use it in GitHub Desktop.
depth-first-search
(define (dfs tree)
(display (car tree))
(newline)
(let loop ((xs (cdr tree)))
(if (not (null? xs))
(begin
(dfs (car xs))
(loop (cdr xs))))))
(dfs '(1 (2 (3 (4)) (5) (6)) (7 (8 (9) (10) (11)) (12 (13 (14))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment