[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] foldl in terms of foldr

Subject: Re: [Haskell-cafe] foldl in terms of foldr
From: Eduard Sergeev
Date: Tue, 26 Jan 2010 07:24:33 -0800 PST
Xingzhi Pan wrote:
> 
> The first argument to foldr is of type (a -> b -> a), which takes 2
> arguments.  But 'step' here is defined as a function taking 3
> arguments.  What am I missing here?

You can think of step as a function of two arguments which returns a
function with one argument (although in reality, as any curried function,
'step' is _one_ argument function anyway):
step :: b -> (a -> c) -> (b -> c)

e.g. 'step' could have been defined as such:
step x g = \a -> g (f a x) 

to save on lambda 'a' was moved to argument list.
-- 
View this message in context: 
http://old.nabble.com/foldl-in-terms-of-foldr-tp27322307p27324376.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>