Reputation: 7015
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"?
Upvotes: 6
Views: 242
Reputation: 91577
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.
Upvotes: 2
Reputation: 3246
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 { ... }
Upvotes: 2