Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed zip/remove when empty branch - patch from cgrand

  • Loading branch information...
commit 4f24b93c4b256a503b862cc5217a9507678fdffd 1 parent cb874e7
@richhickey richhickey authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/clj/clojure/zip.clj
View
8 src/clj/clojure/zip.clj
@@ -212,8 +212,8 @@
[loc]
(if-let [lloc (left loc)]
(loop [loc lloc]
- (if (branch? loc)
- (recur (-> loc down rightmost))
+ (if-let [child (and (branch? loc) (down loc))]
+ (recur (rightmost child))
loc))
(up loc)))
@@ -231,8 +231,8 @@
(throw (new Exception "Remove at top"))
(if (pos? (count l))
(loop [loc (with-meta [(peek l) (assoc path :l (pop l) :changed? true)] ^loc)]
- (if (branch? loc)
- (recur (-> loc down rightmost))
+ (if-let [child (and (branch? loc) (down loc))]
+ (recur (rightmost child))
loc))
(with-meta [(make-node loc (peek pnodes) rs)
(and ppath (assoc ppath :changed? true))]
Please sign in to comment.
Something went wrong with that request. Please try again.