Is such a function familia to the Haskell users?
foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a
foldlWhilefp abs =
case
(bs, p a)
of
([],_) -> a
(_, False) -> a
(b:bs', _) -> foldlWhile f p (f a b) b
On Sat, Nov 20, 2004 at 12:47:58PM +0300, Serge D. Mechveliani wrote:
> Is such a function familia to the Haskell users?
>
> foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a
> foldlWhilefp abs =
> case
> (bs, p a)
> of
> ([],
On Sat, Nov 20, 2004 at 03:48:23PM +, Jorge Adriano Aires wrote:
> > On Sat, Nov 20, 2004 at 12:47:58PM +0300, Serge D. Mechveliani wrote:
> > > foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a
> > > foldlWhilefp abs =
> > > case
> > >
(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