Welcome! Please see the About page for a little more info on how this works.

0 votes
in Collections by

Are there any immutable wrapper around Java arrays in Clojure, similar to Scala's ArraySeq?

What are your thoughts on introducing such a wrapper to Clojure's core?

1 Answer

+1 vote
selected by
Best answer

It already exists, and has exactly the same name. The package is clojure.lang.

To use it, just call seq on the array - the result will be an instance of ArraySeq that wraps the array.

Note that the array is not copied so it shouldn't be modified by something else. Also, for primitive types there are custom classes, e.g. ArraySeq_int, but it's just an implementation detail - just letting you know so you don't start checking for (instance? clojure.lang.ArraySeq x).

Thanks Eugene, precisely what I was looking for!
Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.