[Haskell-cafe] *GROUP HUG*

Ivan Tarasov ivan.tarasov at gmail.com
Thu Jun 2 00:26:29 CEST 2011


On Wed, Jun 1, 2011 at 3:28 AM, Daniel Fischer <
daniel.is.fischer at googlemail.com> wrote:

> On Wednesday 01 June 2011 12:25:06, Adrien Haxaire wrote:
> >  On Wed, 01 Jun 2011 11:46:36 +0200, Henning Thielemann wrote:
> > > Really, you can write foldr in terms of foldl? So far I was glad I
> > > could
> > > manage the opposite direction.
> >foldr (++) (repeat "No way! ")
>

How about this:

myFoldr :: (a -> b -> b) -> b -> [a] -> b
myFoldr f z xs = foldl' (\s x v -> s (x `f` v)) id xs $ z

Cheers,
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110601/43135e6d/attachment.htm>


More information about the Haskell-Cafe mailing list