Created
July 15, 2011 00:00
-
-
Save jamiltron/1083758 to your computer and use it in GitHub Desktop.
Flatten a List
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
;; Flatten a Sequence: Write a function which flattens a sequence. | |
(defn flat [n] | |
(let [x (first n) | |
xs (rest n)] | |
(cond | |
(empty? n) '() | |
(coll? x) (concat (flat x) (flat xs)) | |
:else (cons x (flat xs))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment