How to add a child to a tree using clojure.zip?
问题 Consider the following code (def v (z/vector-zip [1 [2 [3 4]]])) where z refers to clojure.zip. Now, how do I create from v the vector [1 [2 [3 [4 5]]]] using functions from the API for clojure.zip ? So starting with (-> v ... 回答1: Just use function edit (defn edit "Replaces the node at this loc with the value of (f node args)" [loc f & args] (replace loc (apply f (node loc) args))) Example (-> v (z/down) (z/right) (z/down) (z/right) (z/down) (z/right) (z/edit #(do [% 5])) (z/root)) And the