On Mon, Mar 22, 2010 at 10:30:32AM +0000, Johannes Waldmann wrote:
> Nice! - Where's the 'nub'?

A bit longer:

bfs :: Eq a => (a -> [a]) -> a -> [a]
bfs f s = concat $ takeWhile (not . null) $ map snd $ iterate step ([], [s])
  where step (seen, xs) = let seen' = xs++seen in (seen', nub $ [y | x <- xs, y 
<- f x, notElem y seen'])
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to