I was trying to write a function next-branch.

I wrote somthing like:
(use 'clojure.zip)
(def zp (seq-zip '(+ 1 2 (+ 3 4) (+ 5 6))))
(defn next-branch [loc] (second (filter branch? (iterate next loc))))

(next-branch (next-branch (next-branch zp)))
this results in: NullPointerException   clojure.zip/branch? (zip.clj:73)

Reading the docs of next "returns a distinguished loc", this seams to imply 
next should always return a loc even when at the end. The docs of branch? 
"Returns 
true if the node at loc is a branch" seam to imply any loc will do.

So this would lead me to concluded that next always returns a "loc" and 
since branch? is supposed to take a "loc" it should work.

Why doesn't next return a loc at the end? Looking at the code I know "why" 
but is it intended to be this way? If so why?

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to