On Dec 23, 2013, at 3:40 AM, Cedric Greevey wrote: > On Sun, Dec 22, 2013 at 12:26 PM, Lee Spector <lspec...@hampshire.edu> wrote: >> The issue I was rasing is that, 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. >> >> As I mentioned previously this leads to null pointer exceptions in my >> application, and the only ways around it that I see are recoding everything >> without zippers or some nasty special case hackery. > > Point of order: I'm somewhat dubious of the contention that wrapping the > output of the traversal in (filter identity ...) before passing it to > whatever's throwing the NPEs quite qualifies as "nasty special case hackery". > :)
For one thing it wouldn't be quite that simple because in my application I'm not just collecting all of the nodes (from which I could indeed easily filter out nils), but rather doing things like getting or operating on the nth element of the tree, which I reach via n applications of zip/next, and I'd have to add a condition to check each result along the way and not count it if it's nil. And if I have "legitimate" nils in the tree somewhere then I'd have to do something more complicated to distinguish those (which should be counted) from the "phantom" nils that zip/next is inserting in certain circumstances. The bigger point, though, is that if I'm right that this is a bug then I think it's a pretty fundamental one in a core Clojure data structure, and it shouldn't be something that one has to discover and work around. -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.