Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Here ya go. This is flatten in scheme.
- ;; Has a nasty little thing in that it flattens improper lists to proper lists
- ;; but at least it won't die.
- (define (flatten lst)
- (let loop ((lst lst) (acc '()))
- (cond
- ((null? lst) acc)
- ((pair? lst) (loop (car lst) (loop (cdr lst) acc)))
- (else (cons lst acc)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement