Thanks Niels, but what if a java class is not available for rewrite? Say, it is from an external library.
— Sent from Mailbox On Tue, Mar 17, 2015 at 10:01 PM, Niels van Klaveren <niels.vanklave...@gmail.com> wrote: > 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 clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > 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 clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.