Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

For example:

Clojure 1.3.0
user=> (require '(link: clojure.zip :as z))
nil
user=> (-> (z/seq-zip (list 1)) z/down z/remove)
NullPointerException clojure.core/with-meta (core.clj:211)

Possibly the make-node function for seq-zip should be:

(fn (link: node children) (with-meta (or children ()) (meta node)))

4 Answers

0 votes
by

Comment made by: glchapman

Also the docstring for zipper should probably be updated to indicate that the children parameter can be nil.

0 votes
by

Comment made by: chbrown

4+ years later, I also ran into this.

Is there a workaround? I.e., is there a way to remove elements from singleton branches?

0 votes
by

Comment made by: alexmiller

Would be happy to see a patch (although it also needs to backfill some tests too).

One workaround would be something like:

(-> (z/seq-zip (list 1)) (z/edit #(drop 1 %)) z/node)

Or you could use another zipper library like hara.zip which doesn't have remove, but works with delete-right:

(-> (z/seq-zip (list 1)) z/down z/delete-right z/up z/node)

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-941 (reported by glchapman)
...