Skip to content

Instantly share code, notes, and snippets.

@ottonascarella
Last active December 1, 2018 14:19
Show Gist options
  • Save ottonascarella/8faceb07806ae5a038b71b864468ebf8 to your computer and use it in GitHub Desktop.
Save ottonascarella/8faceb07806ae5a038b71b864468ebf8 to your computer and use it in GitHub Desktop.
(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