Created
February 24, 2009 02:30
-
-
Save tyru/69348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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