to-array-2D is a handy function for converting a collection of collections into a 2D java array. Is there a function to go the other way?
I would like to get a vector of vectors from a 2D java array.
to-array-2D is a handy function for converting a collection of collections into a 2D java array. Is there a function to go the other way?
I would like to get a vector of vectors from a 2D java array.
You could do:
(mapv vec the-array)
Although in that case, take into account the documentation of vec
clojure.core/vec
([coll])
Creates a new vector containing the contents of coll. Java arrays
will be aliased and should not be modified.
If you prefer to make a copy (less efficient but safer), do what leeor says in the comment. Shorter version:
(mapv #(into [] %) the-array)
(mapv (partial into []) my-array)