Skip to content

Commit ae2c495

Browse files
committed
Move :end? tag to top level
1 parent ee817f9 commit ae2c495

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/rewrite_clj/zip/zip.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
(defn root
9595
"zips all the way up and returns the root node, reflecting any
9696
changes."
97-
[loc]
98-
(if (= :end (:path loc))
97+
[{:keys [end?] :as loc}]
98+
(if end?
9999
(node loc)
100100
(let [p (up loc)]
101101
(if p
@@ -188,16 +188,16 @@
188188
"Moves to the next loc in the hierarchy, depth-first. When reaching
189189
the end, returns a distinguished loc detectable via end?. If already
190190
at the end, stays there."
191-
[loc]
192-
(if (= :end (:path loc))
191+
[{:keys [end?] :as loc}]
192+
(if end?
193193
loc
194194
(or
195195
(and (branch? loc) (down loc))
196196
(right loc)
197197
(loop [p loc]
198198
(if (up p)
199199
(or (right (up p)) (recur (up p)))
200-
(assoc p :path :end))))))
200+
(assoc p :end? true))))))
201201

202202
(defn prev
203203
"Moves to the previous loc in the hierarchy, depth-first. If already
@@ -213,7 +213,7 @@
213213
(defn end?
214214
"Returns true if loc represents the end of a depth-first walk"
215215
[loc]
216-
(= :end (:path loc)))
216+
(:end? loc))
217217

218218
(defn remove
219219
"Removes the node at loc, returning the loc that would have preceded

0 commit comments

Comments
 (0)