[Haskell-beginners] oddsFrom3 function
akash g
akaberto at gmail.com
Mon Aug 17 06:32:32 UTC 2015
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 <debdutk at gnulinuxed.tk>
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
> 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/d8e90ff7/attachment.html>
More information about the Beginners
mailing list