Search code examples
clojurelist-manipulation

clojure list manipulation multilist to list


Is there a clojure function to do:

((1 2) (3) (5 1) (2)) => (1 2 3 5 1 2)

(def a-list '((1 2) (3) (5 1) (2)))
(my-func a-list)
   ;; =>(1 2 3 5 1 2)

Solution

  • (flatten a-list)
    

    will do the trick as well.

    See:
    http://clojuredocs.org/clojure_core/clojure.core/apply
    http://clojuredocs.org/clojure_core/clojure.core/concat
    http://clojuredocs.org/clojure_core/clojure.core/flatten