[Haskell-cafe] Generalizing takeWhile
Matthias Görgens
matthias.goergens at googlemail.com
Wed Jul 22 12:00:38 EDT 2009
I need to take some elements from the front of a list. However the
criteria are somewhat complex.
> walk f [] = []
> walk f (x:xs) = case f x
> of Just g -> x : walk g xs
> Nothing -> []
For each item the `predicate' f either returns Nothing, when it thinks
we should not take any more elements, or return Just another
`predicate' to apply to the next element.
However the type system does not like my function. How can I mollify it?
More information about the Haskell-Cafe
mailing list