Re: [Haskell-cafe] folds with escapes

2007-07-05 Thread oleg
Can you do dropWhile in terms of foldr? One can write foldr that represents drop or dropWhile of the original foldr. One can do even more: zip two folds. That is, obtain a fold that is equivalent to zipping up two lists represented by the original folds. Even furthermore, one can do all these

Re: [Haskell-cafe] folds with escapes

2007-07-05 Thread Claus Reinke
Can you do dropWhile in terms of foldr? I don't see how. If you are really keen, you might want to try altering the working backwards with tuples version into one which is properly lazy (many people who read the paper pointed out the omission). you might want to mention the story of the

[Haskell-cafe] folds with escapes

2007-07-04 Thread Michael Vanier
I'm sure this has been done a hundred times before, but a simple generalization of foldl just occurred to me and I wonder if there's anything like it in the standard libraries (I couldn't find anything). Basically, I was trying to define the any function in terms of a fold, and my first try

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Stefan O'Rear
On Wed, Jul 04, 2007 at 04:20:20PM -0700, Michael Vanier wrote: I'm sure this has been done a hundred times before, but a simple generalization of foldl just occurred to me and I wonder if there's anything like it in the standard libraries (I couldn't find anything). Basically, I was trying

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Michael Vanier
That's cool -- good point. takeWhile is also trivially defined in terms of foldr: takeWhile p = foldr (\x r - if p x then x:r else []) [] Can you do dropWhile in terms of foldr? I don't see how. Mike Stefan O'Rear wrote: On Wed, Jul 04, 2007 at 04:20:20PM -0700, Michael Vanier wrote: I'm

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Stefan O'Rear
On Wed, Jul 04, 2007 at 05:08:01PM -0700, Michael Vanier wrote: That's cool -- good point. takeWhile is also trivially defined in terms of foldr: takeWhile p = foldr (\x r - if p x then x:r else []) [] Can you do dropWhile in terms of foldr? I don't see how. dropWhile cannot be

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Daniel McAllansmith
On Thursday 05 July 2007 11:20, Michael Vanier wrote: Again, I'm sure this has been done before (and no doubt better); I'd appreciate any pointers to previous work along these lines. Takusen is, if I recall correctly, based around a generalised fold supporting accumulation and early

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Guido Genzone
2007/7/4, Michael Vanier [EMAIL PROTECTED]: That's cool -- good point. takeWhile is also trivially defined in terms of foldr: takeWhile p = foldr (\x r - if p x then x:r else []) [] Can you do dropWhile in terms of foldr? I don't see how. I 'm very bad in english, sorry. Here is a

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Donald Bruce Stewart
dm.maillists: On Thursday 05 July 2007 11:20, Michael Vanier wrote: Again, I'm sure this has been done before (and no doubt better); I'd appreciate any pointers to previous work along these lines. Takusen is, if I recall correctly, based around a generalised fold supporting accumulation

Re: [Haskell-cafe] folds with escapes

2007-07-04 Thread Bernie Pope
On 05/07/2007, at 10:08 AM, Michael Vanier wrote: Can you do dropWhile in terms of foldr? I don't see how. Mike I considered that very question in an article I wrote for the Monad.Reader magazine: http://www.haskell.org/sitewiki/images/1/14/TMR-Issue6.pdf If you are really keen,