
22 Mar
2010
22 Mar
'10
7:42 a.m.
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'])