Last active
December 1, 2018 14:19
-
-
Save ottonascarella/8faceb07806ae5a038b71b864468ebf8 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
(ns flatten-it) | |
(defn flatten-it [coll] | |
(loop [acc [], aseq coll] | |
(let [[fst & rst] aseq] | |
(cond | |
(empty? aseq) (seq acc) | |
(sequential? fst) (recur (into acc (flatten-it fst)) rst) | |
:otherwise (recur (into acc [fst]) rst))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment