On Saturday 20 November 2004 10:47, Serge D. Mechveliani wrote:
> Is such a function familia to the Haskell users?
>
> foldlWhile :: (a -> b -> a) -> (a -> Bool) -> a -> [b] -> a
Maybe this link is of interest to you:
http://okmij.org/ftp/Haskell/#fold-stream
Ben
--
Top level things with iden
To my question of
>> 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) bs'
>>
>> fol
(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
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
> > >
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
> ([],
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