[Haskell-cafe] foldlWhile

2004-11-20 Thread Serge D. Mechveliani
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

Re: [Haskell-cafe] foldlWhile

2004-11-20 Thread Dylan Thurston
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 > ([],

Re: [Haskell-cafe] foldlWhile

2004-11-20 Thread Dylan Thurston
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 > > >

Re: [Haskell-cafe] foldlWhile

2004-11-20 Thread Jorge Adriano Aires
(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

Re: [Haskell-cafe] foldlWhile

2004-11-21 Thread Serge D. Mechveliani
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

Re: [Haskell-cafe] foldlWhile

2004-11-22 Thread Benjamin Franksen
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