Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Trying to understand the foldl type? (Angus Comber)
   2. Re:  Trying to understand the foldl type? (Bob Ippolito)
   3. Re:  Trying to understand the foldl type? (Kim-Ee Yeoh)


----------------------------------------------------------------------

Message: 1
Date: Tue, 24 Dec 2013 13:19:42 +0000
From: Angus Comber <[email protected]>
To: Haskell Beginners <[email protected]>
Subject: [Haskell-beginners] Trying to understand the foldl type?
Message-ID:
        <CAAtGUhWfmF7JQvSh270xN9KbHVa2fxCe6f=wxyxtchqu79f...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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/9ba8917f/attachment-0001.html>

------------------------------

Message: 2
Date: Tue, 24 Dec 2013 05:47:23 -0800
From: Bob Ippolito <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Trying to understand the foldl type?
Message-ID:
        <CACwMPm-q=kk3oaxt611ur5wxcakuubvrb8nln4lefzmlrnc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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-0001.html>

------------------------------

Message: 3
Date: Tue, 24 Dec 2013 22:21:52 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Trying to understand the foldl type?
Message-ID:
        <CAPY+ZdSddOwVmxdqLsPaF62V47aXtB=refbyxk0hat+ux4s...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Tue, Dec 24, 2013 at 8:19 PM, Angus Comber <[email protected]> wrote:

> foldl :: (a -> b -> a) -> a -> [b] -> a
>
> Eg I might do something like this:
>
> foldl (+) 0 [1..10]
>

Try the following in ghci to see if you get an idea of what's going on:

:t foldl

:t foldl (+)

:t foldl (+) 0

:t foldl (+) 0 [1..10]

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20131224/3ab952d4/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 66, Issue 19
*****************************************

Reply via email to