[Haskell-beginners] oddsFrom3 function

akash g akaberto at gmail.com
Mon Aug 17 06:39:12 UTC 2015


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 <akaberto at gmail.com> 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 <debdutk at gnulinuxed.tk>
> 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
>> Beginners at haskell.org
>> 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.html>


More information about the Beginners mailing list