Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a Java array into a Clojure list or sequence?

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?

like image 811
jpaugh Avatar asked Mar 10 '16 20:03

jpaugh


1 Answers

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.

like image 168
jpaugh Avatar answered Sep 30 '22 19:09

jpaugh