Thank you very much, Tassilo!
Are Graph and Vertex classes from the public API?

On 24 ноя, 13:02, Tassilo Horn <tass...@member.fsf.org> wrote:
> ru <soro...@oogis.ru> writes:
> > Can anybody point out good (idiomatic) examples of using protocols for
> > extending functionality of existing classes?
>
> Here's one that I have in my code:
>
> --8<---------------cut here---------------start------------->8---
> (defprotocol VSeq
>   "Protocol for types supporting vseq."
>   (vseq-internal [this tm]
>         "Returns a lazy seq of the graph's vertices restricted by type
>         matcher `tm', or the vertices following this vertex."))
>
> (extend-protocol VSeq
>   Graph
>   (vseq-internal
>     [g tm]
>     (lazy-seq
>      (let [f (first-vertex g tm)]
>        (and f (cons f (vseq-internal f tm))))))
>   Vertex
>   (vseq-internal
>     [v tm]
>     (lazy-seq
>      (let [n (next-vertex v tm)]
>        (and n (cons n (vseq-internal n tm)))))))
> --8<---------------cut here---------------end--------------->8---
>
> Graph and Vertex are existing Java classes.
>
> Bye,
> Tassilo
> --
> (What the world needs (I think) is not
>       (a Lisp (with fewer parentheses))
>       but (an English (with more.)))
> Brian Hayes,http://tinyurl.com/3y9l2kf

-- 
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

Reply via email to