summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchim Passen <achim.passen@gmail.com>2009-08-27 15:17:58 +0200
committerRich Hickey <richhickey@gmail.com>2009-11-24 08:07:05 -0500
commit146f3614d100e9bce421afdcceee67aa0b956bb8 (patch)
tree345c8d182ee4d81f33f78d04d09bb26319eb5532
parent81e19ddd9973841894767d89465979195242afed (diff)
fixed zip/down on leaves, refs #185
Signed-off-by: Rich Hickey <richhickey@gmail.com>
-rw-r--r--src/clj/clojure/zip.clj15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/clj/clojure/zip.clj b/src/clj/clojure/zip.clj
index 57b3b21b..7423513f 100644
--- a/src/clj/clojure/zip.clj
+++ b/src/clj/clojure/zip.clj
@@ -96,13 +96,14 @@
"Returns the loc of the leftmost child of the node at this loc, or
nil if no children"
[loc]
- (let [[node path] loc
- [c & cnext :as cs] (children loc)]
- (when cs
- (with-meta [c {:l []
- :pnodes (if path (conj (:pnodes path) node) [node])
- :ppath path
- :r cnext}] ^loc))))
+ (when (branch? loc)
+ (let [[node path] loc
+ [c & cnext :as cs] (children loc)]
+ (when cs
+ (with-meta [c {:l []
+ :pnodes (if path (conj (:pnodes path) node) [node])
+ :ppath path
+ :r cnext}] ^loc)))))
(defn up
"Returns the loc of the parent of the node at this loc, or nil if at