Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. Re: oddsFrom3 function (Kim-Ee Yeoh)
2. Re: oddsFrom3 function (akash g)
3. oddsFrom3 function (Debdut Karmakar)
4. Re: oddsFrom3 function (akash g)
5. Re: [Haskell-cafe] oddsFrom3 function (Daniel Trstenjak)
----------------------------------------------------------------------
Message: 1
Date: Mon, 17 Aug 2015 14:21:45 +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] oddsFrom3 function
Message-ID:
<CAPY+ZdSESnROxj+keZ-UQ2d7ZKfs670ju8mi+OUqMegp=h8...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Mon, Aug 17, 2015 at 1:32 PM, Debdut Karmakar <[email protected]>
wrote:
> Sorry, I wrote a wrong function, the correct version is:
>
> oddsFrom3 :: [Integer]
> oddsFrom3 = 3 : map (+2) oddsFrom3
>
You can get some idea of lambda evaluation here:
http://chrisuehlinger.com/LambdaBubblePop/
(Alas it doesn't support let expressions much less let rec.)
Once you have a modicum of intuition, you're now ready to appreciate the
illustrated step-by-step evaluation of this infinite list:
http://stackoverflow.com/a/19749422
Based on the SO answer, you can now work out your function on your own.
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/12c3c48b/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 17 Aug 2015 14:12:11 +0530
From: akash g <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] oddsFrom3 function
Message-ID:
<CALiga_fgP9=MSeiB4dF01yFuf354mccqX0npY35+7ZLEut0=p...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Rein,
The initial version which the OP posted doesn't have a terminal value.
The OP had posted the version that he'd wanted clarification on.
On Mon, Aug 17, 2015 at 12:40 PM, Rein Henrichs <[email protected]>
wrote:
> It will absolutely work. Lists can be infinite in Haskell and infinite
> lists are productive:
>
> ?> take 5 oddsFrom3
> [3,5,7,9,11]
>
>
> On Mon, Aug 17, 2015 at 12:05 AM Debdut Karmakar <[email protected]>
> wrote:
>
>> On 2015-08-17 02:35, akash g wrote:
>>
>> Not a problem. And I should have thought about what you wanted too.
>>
>> This version will give you an infinite list of odd numbers from 3.
>>
>>
>> On Mon, Aug 17, 2015 at 12:02 PM, Debdut Karmakar <[email protected]>
>> wrote:
>>
>>> Sorry, I wrote a wrong function, the correct version is:
>>>
>>> oddsFrom3 :: [Integer]
>>> oddsFrom3 = 3 : map (+2) oddsFrom3
>>> --
>>>
>>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>>
>> _______________________________________________
>> Beginners mailing
>> [email protected]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>> I know that it will evaluate to a list of odd numbers >= 3, but how?
>>
>> Thanks, anyway.
>> --
>>
>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/10c45095/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 17 Aug 2015 04:44:55 -0400
From: Debdut Karmakar <[email protected]>
To: Haskell Beginner Mailing List <[email protected]>, Haskell
Cafe Mailing List <[email protected]>
Subject: [Haskell-beginners] oddsFrom3 function
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
I am a haskell beginner and wondering how the following function
works (in procedure) :
oddsFrom3 :: [Integer]
oddsFrom3 = 3 : map
(+2) oddsFrom3
Thanks for your help.
--
A GNU [1] LINUX [2] Patron
Links:
------
[1] http://gnu.org
[2] http://www.linuxfoundation.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/6bba7136/attachment-0001.html>
------------------------------
Message: 4
Date: Mon, 17 Aug 2015 14:16:10 +0530
From: akash g <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] oddsFrom3 function
Message-ID:
<caliga_eposppcxvoz4bkpwh82f66jabhoa67ggkz1rcjsq6...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
You can also peruse SICP for knowing about how lazy evaluation works. The
explanations are nice. It is in lisp, though.
https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5
On Mon, Aug 17, 2015 at 2:12 PM, akash g <[email protected]> wrote:
> Hi Rein,
>
> The initial version which the OP posted doesn't have a terminal value.
> The OP had posted the version that he'd wanted clarification on.
>
> On Mon, Aug 17, 2015 at 12:40 PM, Rein Henrichs <[email protected]>
> wrote:
>
>> It will absolutely work. Lists can be infinite in Haskell and infinite
>> lists are productive:
>>
>> ?> take 5 oddsFrom3
>> [3,5,7,9,11]
>>
>>
>> On Mon, Aug 17, 2015 at 12:05 AM Debdut Karmakar <[email protected]>
>> wrote:
>>
>>> On 2015-08-17 02:35, akash g wrote:
>>>
>>> Not a problem. And I should have thought about what you wanted too.
>>>
>>> This version will give you an infinite list of odd numbers from 3.
>>>
>>>
>>> On Mon, Aug 17, 2015 at 12:02 PM, Debdut Karmakar <[email protected]
>>> > wrote:
>>>
>>>> Sorry, I wrote a wrong function, the correct version is:
>>>>
>>>> oddsFrom3 :: [Integer]
>>>> oddsFrom3 = 3 : map (+2) oddsFrom3
>>>> --
>>>>
>>>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron
>>>>
>>>> _______________________________________________
>>>> Beginners mailing list
>>>> [email protected]
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>>
>>>>
>>> _______________________________________________
>>> Beginners mailing
>>> [email protected]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>> I know that it will evaluate to a list of odd numbers >= 3, but how?
>>>
>>> Thanks, anyway.
>>> --
>>>
>>> A* GNU <http://gnu.org> Linux <http://www.linuxfoundation.org/>* Patron
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/aa9f61ae/attachment-0001.html>
------------------------------
Message: 5
Date: Mon, 17 Aug 2015 10:49:50 +0200
From: Daniel Trstenjak <[email protected]>
To: [email protected], Haskell Beginner Mailing List
<[email protected]>
Subject: Re: [Haskell-beginners] [Haskell-cafe] oddsFrom3 function
Message-ID: <20150817084950.GA18244@machine>
Content-Type: text/plain; charset=us-ascii
Hi Debdut,
On Mon, Aug 17, 2015 at 04:44:55AM -0400, Debdut Karmakar wrote:
> I am a haskell beginner and wondering how the following function works (in
> procedure) :
>
>
> oddsFrom3 :: [Integer]
> oddsFrom3 = 3 : map (+2) oddsFrom3
>
>
> Thanks for your help.
Try to expand a few steps of the recursion by hand e.g.:
3 : (map (+2) (3 : map (+2) (3 : map (+2) ...)))
As you can see, the deeper you go more 'map (+2)' are applied to '3'.
Greetings,
Daniel
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 86, Issue 13
*****************************************