Went off half-cocked there. The remainder: (edit-parents #(= 10 (get-in % ["a" "b"])) #(update % "children" reverse), data-zipper)
Would have the effect of reversing the order of the children in each node which possesses a child having a "b" attribute set to 10. You could probably express this much better with a library which allows locations in data structures to be described in an XPath-like way (and your data actually looks a lot like it is the result of parsing markup - see clojure.data.xml and xml-zip if so) -- or there's probably some better zipper approach that somebody who's really into zippers could come up with. If you don't want to depend on an external library, and you lose your enthusiasm for zippers, you could write a function which goes over the structure and returns pairs of [[path] attributes], where path is a sequence of keys/indices suitable for passing to update-in/assoc-in etc., and attributes is the value of the "a" key at each level. In general, if there aren't multiple keys similar to "a" in each map (i.e. it's always some value pointing to some map, and the value is not always "a"), this kind of layout may be easier (e.g. to destructure) {:tag "a" :attrs {:b 10} :children [...]}} Take care, Moe -- 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.