Skip to content

Instantly share code, notes, and snippets.

@ilovejs
Created April 2, 2015 06:25
Show Gist options
  • Save ilovejs/3eb700ed49ecf45e63df to your computer and use it in GitHub Desktop.
Save ilovejs/3eb700ed49ecf45e63df to your computer and use it in GitHub Desktop.
recursive function in clojure
(defn flat [x]
(if (coll? x)
(if (empty? x)
[]
(concat (flat (first x)) (flat (rest x))))
[x]))
(flat '((1 2) 3 [4 [5 6]]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment