[CLJ-1317] clojure.zip/seq-zip returns spurious nils during traversal Created: 31/Dec/13 Updated: 05/Feb/14
Problem reported by Lee Spector on the mailing list:
Here's a quote from Lee's post describing the problem:
The underlying cause is that seq-zip passes identity as the children argument to zipper. Applied to (), this returns (), which is truthy, leading zipper to descend into a non-existent subtree.
One natural solution would be to use seq in place of identity:
With this change, no nil is produced in the example above. Patch with this change forthcoming.
|Comment by Michał Marczyk [ 31/Dec/13 5:52 PM ]|
Note that the docstring of clojure.zip/zipper asks that the children argument return a seq of children. The rest of clojure.zip, however, expects nil to be returned when there are no children, as evidenced by this problem.
One could argue that this behaviour of the rest of clojure.zip should be fixed, but I think it makes sense and is convenient. Perhaps the docstring should be adjusted, though.