Skip to content

Commit 1440172

Browse files
author
Yannick Scherer
committed
Fixed prewalk.
1 parent 8d6ff2f commit 1440172

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/rewrite_clj/zip.clj

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,10 @@
407407
only apply the function to nodes matching it."
408408
([zloc f] (prewalk zloc (constantly true) f))
409409
([zloc p? f]
410-
(loop [loc (subzip zloc)]
411-
(if (z/end? loc)
412-
(z/replace zloc (z/root loc))
413-
(if-let [n0 (find loc next p?)]
414-
(if-let [n1 (f n0)]
415-
(recur (z/next n1))
416-
(recur (z/next n0)))
417-
(z/replace zloc (z/root loc)))))))
410+
(loop [loc (subzip zloc)
411+
prv loc]
412+
(if-let [n0 (find loc next p?)]
413+
(if-let [n1 (f n0)]
414+
(recur (next n1) n1)
415+
(recur (next n0) n0))
416+
(z/replace zloc (z/root prv))))))

0 commit comments

Comments
 (0)