If a java class implements Iterable, it automatically supports seq.
On Tuesday, March 17, 2015 at 11:34:17 AM UTC+1, juvenn wrote:
>
> Dear all,
>
> Given a node type from singly linked list:
>
> class Node {
> int val;
> Node next;
> }
>
> How do I extend it so `(seq node)` will return a sequence of values? And
> generally first, rest, and next will work on node too.
>
> While in Java, we could define the class to implement Iterable to achieve
> this. In Clojure we do have `extend-type`, but it seems not accepting
> interfaces to extend, nor do I find protocol for seqable.
>
> So generally, given a class defined in Java, assuming it is not available
> for rewrite, how shall we extend the class to participate in sequence
> operations in Clojure?
>
> Thanks in advance!
>
> —
> Sent from Mailbox <https://www.dropbox.com/mailbox>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.