[Haskell-cafe] Re: searching via zipper over a tree

Graham Fawcett graham.fawcett at gmail.com
Thu Apr 24 12:02:51 EDT 2008

On Thu, Apr 24, 2008 at 12:44 AM, Graham Fawcett
<graham.fawcett at gmail.com> wrote:
>  I'm studying zippers (and by extension, the State monad), and have
>  written a function for finding the first node-location in a 'zippered'
>  tree that satisfies a predicate:
>  http://paste.lisp.org/display/59636
>  (The code uses Krasimir Angelov's Data.Tree.Zipper.) My code works,
>  but I suspect that I'm working too hard. I would appreciate any
>  comments!

I did figure out an easier way: lazily walk every location in the
tree, and take the first matching location.

Much cleaner (though comments are still welcome.)

Haskell seems to have a high 'commute factor' -- many solutions appear
not at the keyboard, but while driving home...


More information about the Haskell-Cafe mailing list