[Haskell-beginners] Trying to understand the foldl type?
Bob Ippolito
bob at redivi.com
Tue Dec 24 13:47:23 UTC 2013
Given foldl (+) 0 [1..10]
(+) is (a -> b -> a)
0 is a
[1..10] is [b]
and the final a is the result of the expression.
On Tuesday, December 24, 2013, Angus Comber wrote:
> The type is:
>
> foldl :: (a -> b -> a) -> a -> [b] -> a
>
> Eg I might do something like this:
>
> foldl (+) 0 [1..10]
>
> so taking (a -> b -> a)
>
> leftmost a is (+)
> b is 0
> right a is what? The first value in the list?
>
> Then -> ?
>
> [b] ? Is this like the temporary recursion calculation?
>
> final -> a is the result?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131224/bdbde84d/attachment.html>
More information about the Beginners
mailing list