ClojureDocs

Nav

Namespaces

make-node

clojure.zip

Available since 1.0
  • (make-node loc node children)
Returns a new branch node, given an existing node and new
children. The loc is only used to supply the constructor.
1 Example
;; Useful to perform operations on locations without knowing the
;; internals of the zipper. For example, here's a generic remove-child to remove
;; the first children from a node
(require '[clojure.zip :as zip])

(def vzip
  (zip/vector-zip
    [[1 2]
     [3 4 [5 10 [11 12]]]
     [13 14]]))

(defn remove-child [loc]
  (zip/replace loc 
    (zip/make-node loc (zip/node loc) (rest (zip/children loc)))))

(-> vzip zip/down zip/rightmost remove-child zip/root)
;; [[1 2] [3 4 [5 10 [11 12]]] [14]]
See Also
No see-alsos for clojure.zip/make-node
0 Notes
No notes for make-node