I'm trying to use specter/zipper
to create a custom zipper. I have the clojure.zip/zipper
working ok, but when I attempt to wrap it using specter/zipper I get this error:
anh-front.tree> (def tz (specter-tree-zip test-tree))
#object[TypeError TypeError: anh_front.tree.specter_tree_zip.call is not a function]
nil
Heres the code, I have clojure.zip
required as zip
and specter.zip
required as sz
(defn tree-zip
"Returns a zipper for tree elements given a root element"
[root]
(zip/zipper (complement string?)
(fn [node] (if (:expanded node)
(seq (:children node))))
(fn [node children]
(assoc node :children (and children (apply vector children))))
root))
(def specter-tree-zip (sz/zipper tree-zip))
Any idea what I have done wrong?@soulflyer sz/zipper
returns a navigator, not a function
you use it in a path to navigate to the zipper object
e.g. (transform [specter-tree-zip sz/DOWN ...
ah, that makes sense. I wrongly assumed I could just drop it in where I had used clojure.zip/zipper
Thanks!