On Tue, Nov 26, 2013 at 08:30:15PM -0800, martin_clausen wrote:
> To use the zipper library you have to be able to provide branch? children
> and make-node functions that apply to your data structure.
>
> I don't see a way to provide a meaningful branch? or children function for
> the structure you describe. Vector? will not work as branch? as it will not
> return true if passed the first element in a vector, and next will not work
> as it will not return the children if passed the first element of a vector.
We can write our own functions, though:
(defn children? [n]
(and (vector? n) (next n)))
(defn make-node [n children]
(vec (cons (first n) children)))
(defn tree-zipper [v]
(z/zipper children? next make-node v))
Dario: I tried this with your gist, and the code in your previous email,
and as far as I could tell it worked, so I hope that helps!
Carlo
--
--
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/groups/opt_out.