marick / fp-oo

Code samples and exercise solutions for /Functional Programming for the Object-Oriented Programmer/
143 stars 49 forks source link

Ecstatic Earthworm - error in text on PDF page 169 #13

Closed gregspurrier closed 12 years ago

gregspurrier commented 12 years ago

In "The Trickiness of Removing" on page 169 of the PDF version of Ecstatic Earthworm, there is either an error in the text or I am confused about what you are trying to convey:

Remember that zip/next moves depth-first, not breadth-first. The next node after (+ 1 HERE) is 1, not (2 3).

From the example that is in play, I would expect this to say "The next node after (+ 1 HERE) is +, not (2 3)." since the depth-first walk would take you into the seq at the left-most position. I've confirmed this with the REPL:

user=> (def zipper (zip/seq-zip '((+ 1 HERE) (+ 2 3))))
#'user/zipper
user=> (-> zipper zip/down zip/node)
(+ 1 HERE)
user=> (-> zipper zip/down zip/next zip/node)
+

This is using the original zipper, not the one resulting from the removal, but I see the same thing with the latter as well.

marick commented 12 years ago

You're correct. Fixed.