Skip to content

Instantly share code, notes, and snippets.

@tyru
Created February 24, 2009 02:30
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 tyru/69348 to your computer and use it in GitHub Desktop.
Save tyru/69348 to your computer and use it in GitHub Desktop.
(use srfi-1)
; flat-list tree
(define (flat-list tree)
(cond
[(null? tree) '()]
[(list? (car tree))
(append (flat-list (car tree)) (flat-list (cdr tree)))]
[else (cons (car tree) (flat-list (cdr tree)))]))
;; main
(define (main args)
(print (flat-list '(1 2 (3 4) 5 (6 (7) (8 9)))))
(print (flat-list (make-list 10 '(1 2 3 4))))
0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment