I am using a Java class that represents a sequence of results (somewhat like a Clojure vector).
I would like to use this class with typical Clojure sequence functions (i.e. I want the class to behave as if it supported sequence abstraction), however I cannot change the class so I cannot implement it clojure.lang.Seqable or similar. Also, annoyingly, the class does not implement java.util.Collection or java.lang.Iterable .
I see several options:
- Use
iterator-seq for the (existing) iterator object. - Wrap the object in another class that implements
java.util.Collection / clojure.lang.Sequable - Create a function that builds a vector or Clojure sequence by querying an object
Are there any other options? What is the best approach?
java clojure sequence
mikera
source share