The implementation of seq-zip uses seq? as its branching predicate. As a 
result the zipper goes down on () thinking it can have children:

user=> (seq? ())
true
user=> (seq? {})
false
user=> (seq? #{})
false
user=> (seq? [])
false

On Sunday, December 29, 2013 10:14:23 AM UTC-8, Lee wrote:
>
>
> I realize that many people are on holiday, but I'm hoping to get some 
> clarity about how to proceed with respect to this issue in the near future. 
>
> Can anyone tell if I'm right that this is a bug in clojure.zip? If so, 
> then is the right thing to do to post an issue on JIRA? 
>
> I've re-included the crux of the issue [slightly edited and recombined] 
> below. 
>
> Thanks, 
>
>  -Lee 
>
>
> On Dec 21, 2013, at 11:49 AM, Lee Spector wrote: 
> > 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 [... deleted ...] 
> > 
> > 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. 
>
> > [That is,] when traversing '(() 0) with zip/next, one should first visit 
> the root, then (), and then 0. But what actually happens is that between 
> then () and the 0 one lands on a non-existent nil node. So one ends up 
> visiting 4 nodes when there are only 3, and the extra one is a nil. 
>
>

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