[Haskell-beginners] oddsFrom3 function

akash g akaberto at gmail.com
Mon Aug 17 08:42:11 UTC 2015


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 <rein.henrichs at gmail.com>
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 <debdutk at gnulinuxed.tk>
> 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 <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
>>>
>>>
>> _______________________________________________
>> Beginners mailing listBeginners at haskell.orghttp://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
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
> _______________________________________________
> 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/10c45095/attachment.html>


More information about the Beginners mailing list