I recall a while ago running into this. I ended up with the following:

(defn stop?
  "Returns true if there is no point continuing past the specified loc.

  loc may be null or (z/end?).

  This is only here because z/up returns nil rather than something (z/end? will 
work with)."
  [loc]
  (or (nil? loc) (z/end? loc)))

and then iterating while not stop?

I also remember running into a situation where loc wasn't nil but z/node
was(!).

I can't recall the exact details but that might help...

Hussein B. writes:

> Hi,
>
> I have this structure:
>
> (def s [{"n" {"id" "a"} "d" 2 "children" [{"n" {"id" "c"} "d" 4 "children"
> []}]} {"n" {"id" "b"} "d" 3 "children" []}])
>
>
>
> And I wrote a function with zippers to traverse it:
>
>  (defn traverse [col]
>   (loop [z col]
>     (if (= (z/next z) z)
>     z
>     (if (z/branch? z)
>       (recur (z/next z))
>       (recur (-> z println z/next))))))
>
>
> But I'm getting: NullPointerException   clojure.zip/next (zip.clj:236)
>
> Any ideas?
>
> Thanks for help.

--
Sent with my mu4e

-- 
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/d/optout.

Reply via email to