[Haskell-cafe] folds with escapes

Guido Genzone guidog87 at gmail.com
Wed Jul 4 20:27:46 EDT 2007


2007/7/4, Michael Vanier <mvanier at cs.caltech.edu>:
> 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 solution....
dropWhile in terms of fordr

Author : Graham Hutton
www.cs.nott.ac.uk/~gmh/fold.ps


More information about the Haskell-Cafe mailing list