[Haskell-cafe] Re: breadth first search one-liner?
Bertram Felgenhauer
bertram.felgenhauer at googlemail.com
Mon Mar 22 10:46:33 EDT 2010
Bertram Felgenhauer wrote:
> or
> bfs next start = lefts . takeWhile (not . null)
I copied the wrong version. This should be
bfs next start = rights . concat . takeWhile (not . null)
-- rest unchanged
. unfoldr (Just . span (either (const False) (const True)) . tail)
$ fix (nub . (Left 0 :) . (Right start :)
. (>>= either ((:[]) . Left . succ) (map Right . next)))
Bertram
More information about the Haskell-Cafe
mailing list