Dear Clojurians, I'd like to propose a clojure.zip/goto function. It is basically the inverse of the clojure.zip/path function, ie. it takes a location and a path and walks through the zipper to the given node and returns its loc.
(defn goto "Follow along the path from the given loc. In case the path is not contained in the zipper, an exception is thrown. The empty path is always contained and leaves the loc as is." [loc p] (if-let p (seq p) (cond (= (node loc) (first p)) (recur (down loc) (rest p)) (right loc) (recur (right loc) p) :else (throw (new Exception "path not in tree"))) loc)) Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---