When I step through a zipper made from a nested list via seq-zip, I get 
extraneous nils after processing a nested (). 

Is this somehow expected behavior, or a bug, or am I misunderstanding something 
fundamental?

The problem seems to arise only when an nested empty list is present, not other 
nested lists and not other nested empty sequences (see example at bottom for 
this bit).

Here's an illustration, stepping through '(() 0) with next and printing the 
node at each step:

(loop [z (zip/seq-zip '(() 0))]
  (if (zip/end? z)
    :done
    (do (println (zip/node z))
      (recur (zip/next z)))))

That produces:

(() 0)
()
nil
0
:done

I don't expect the nil to be there.

If I do this with a 1 in place of the () then it works as I expect:

(loop [z (zip/seq-zip '(1 0))]
  (if (zip/end? z)
    :done
    (do (println (zip/node z))
      (recur (zip/next z)))))

produces:

(1 0)
1
0
:done

It also works as I expect if I put (1) in place of (), suggesting that it's not 
a problem with stepping over nested lists in general, but just with stepping 
over ():

(loop [z (zip/seq-zip '((1) 0))]
  (if (zip/end? z)
    :done
    (do (println (zip/node z))
      (recur (zip/next z)))))

produces:

((1) 0)
(1)
1
0
:done

However, if I use non-list sequences then things seem to work as I would expect:

(loop [z (zip/seq-zip (seq [[] 0]))]
  (if (zip/end? z)
    :done
    (do (println (zip/node z))
      (recur (zip/next z)))))

produces:

([] 0)
[]
0
:done

This is with Clojure 1.5.1. 

It's leading to null pointer exceptions in my application, so any explanations 
or fixes or pointers would be very much appreciated.

Thanks,

 -Lee

-- 
-- 
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