8

How do I convert a Java array into a Clojure sequence data structure, such as a list, or other sequence?

This question shows how to do the inverse; The Clojure docs show how to create, mutate, and read arrays; but is there a built-in way to convert them to lists, or some other Clojure-native sequence?

Community
  • 1
  • 1
jpaugh
  • 6,634
  • 4
  • 38
  • 90
  • I just wanted a Clojure-native data type, so that I could work with it more easily with the repl. I see that vector is different, so I'll remove it. – jpaugh Mar 11 '16 at 14:58

1 Answers1

16

Yes, there is a way to convert an array to a list! The code (seq java-array-here) will convert the array into an ArraySeq, which implements ISeq, and thus can be treated like any other Clojure sequence.

jpaugh
  • 6,634
  • 4
  • 38
  • 90