(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.
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to