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. oddsFrom3 function (Debdut Karmakar)
2. Re: oddsFrom3 function (Debdut Karmakar)
3. Re: oddsFrom3 function (akash g)
4. Re: oddsFrom3 function (akash g)
5. Re: oddsFrom3 function (akash g)
6. Re: oddsFrom3 function (Debdut Karmakar)
7. Re: oddsFrom3 function (Rein Henrichs)
----------------------------------------------------------------------
Message: 1
Date: Mon, 17 Aug 2015 02:25:25 -0400
From: Debdut Karmakar <[email protected]>
To: Haskell Beginner 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 = map (+2)
oddsFrom3
Thanks for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/2d81df18/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 17 Aug 2015 02:32:26 -0400
From: Debdut Karmakar <[email protected]>
To: <[email protected]>
Subject: Re: [Haskell-beginners] oddsFrom3 function
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Sorry, I wrote a wrong function, the correct version is:
oddsFrom3
:: [Integer]
oddsFrom3 = 3 : map (+2) oddsFrom3
--
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/7bdd4dee/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 17 Aug 2015 12:02:32 +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_fO3dKbzY_Vma9vT978mvpCK=0XVMSgU7xvrV2jQ=f...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Well, it won't work. Oh, it will compile and you can run it too (stuck in
a infinte loop if you try to force it in any way). Compilation happens
because this satisfies the type solver. However, the compiler cannot
ensure non-termination of said program. Just unrolling it should show you
what's wrong with it.
Unroll once:
oddsForm3 = map (+2) (map (+2) oddsForm3)
Unroll again:
oddsForm3 = map (+2) (map (+2) (map (+2) oddsForm3)
And you can keep on going. It will never evaluate to a terminal value.
On Mon, Aug 17, 2015 at 11:55 AM, Debdut Karmakar <[email protected]>
wrote:
> I am a haskell beginner and wondering how the following function works (in
> procedure) :
>
>
> oddsFrom3 :: [Integer]
> oddsFrom3 = map (+2) oddsFrom3
>
>
> Thanks for your help.
>
> _______________________________________________
> 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/d8e90ff7/attachment-0001.html>
------------------------------
Message: 4
Date: Mon, 17 Aug 2015 12:05:54 +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_e-nkaz8aq5b7o5t43khytsjztojnr1ebwjbbrx8jk...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/5331a746/attachment-0001.html>
------------------------------
Message: 5
Date: Mon, 17 Aug 2015 12:09:12 +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_cD8rayv5Cc2KgbsA4h=jhlevjv9drfqm1_88ecypz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Do note that if you force it so that it the value needs the last element,
it will be stuck in an infinite loop of request-> response loop.
Here's what will happen/
last [3,5 ..] -- Same thing as your function
This will be forced to
last [3,5, 7 ..]
which will be forced till it terminates (which is never). So, be careful
with that. However, things like this are perfectly fine.
head [3,5 ..] yields 3
takeWhile (<10) [3,5 ..] yields [3,5,7,9]
On Mon, Aug 17, 2015 at 12:05 PM, akash g <[email protected]> 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/026bde3c/attachment-0001.html>
------------------------------
Message: 6
Date: Mon, 17 Aug 2015 03:05:36 -0400
From: Debdut Karmakar <[email protected]>
To: <[email protected]>
Subject: Re: [Haskell-beginners] oddsFrom3 function
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
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 [1]
LINUX [2] Patron
>> _______________________________________________
>>
Beginners mailing list
>> [email protected]
>>
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners [3]
>
>
_______________________________________________
> Beginners mailing
list
> [email protected]
>
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners [3]
I know
that it will evaluate to a list of odd numbers >= 3, but how?
Thanks,
anyway.
--
A GNU [1] LINUX [2] Patron
Links:
------
[1]
http://gnu.org
[2] http://www.linuxfoundation.org/
[3]
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/18257ac5/attachment-0001.html>
------------------------------
Message: 7
Date: Mon, 17 Aug 2015 07:10:59 +0000
From: Rein Henrichs <[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:
<cajp6g8zasr1kvt1zdu1o2n471c1qrm5hymd-9mfjje2bvdr...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150817/430f07c8/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 86, Issue 12
*****************************************