diff options
author | Achim Passen <achim.passen@gmail.com> | 2009-08-27 15:17:58 +0200 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-11-24 08:07:05 -0500 |
commit | 146f3614d100e9bce421afdcceee67aa0b956bb8 (patch) | |
tree | 345c8d182ee4d81f33f78d04d09bb26319eb5532 | |
parent | 81e19ddd9973841894767d89465979195242afed (diff) |
fixed zip/down on leaves, refs #185
Signed-off-by: Rich Hickey <richhickey@gmail.com>
-rw-r--r-- | src/clj/clojure/zip.clj | 15 |
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 |