I have a bunch of Scala classes (like Lift's Box, Scala's Option, etc.) that I'd like to use in Clojure as a Clojure ISeq.
How do I tell Clojure how to make these classes into an ISeq so that all the various sequence related functions "just work"?
To build on Arthur's answer, you can provide a generic wrapper class in Scala along these lines:
class WrapCollection(repr: TraversableOnce[_]) extends clojure.lang.Seqable { ... }
If the classes implement the Iterable
interface then you can just call seq
on them to get a seqeuence. Most of the functions in the sequence library will do this for you though so in almost all normal cases you can just pass them to seq functions like first
and count
as is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With