
20 Nov
2004
20 Nov
'04
4:55 p.m.
(opss just noticed I did a reply-to)
The following is closer to the original, but doesn't work when the whole list is folded (i.e., p always satisfied): foldlWhile f p a = head . dropWhile p . scanl f a
Serge's version returns the last 'a' that satisfies 'p', while yours Not really.
returns the first 'a' that does not satisfy 'p'. This should be an equivalent version: Yeap, just like his,
foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a foldlWhile f p a bs = <snip> (_, False) -> a <snip> It tests the accumulator with p, and returns it on "false". J.A.