
I have two version of factorial as follows:
fac = 1.0: zipWith (*) [1.0 ..] fac
fact = 1.0: [ f | f <- zipWith (*) [1.. ] fact ]
Could some explain why does facBad run out of stack memory while fact work fine? i.e. ... > take 5 fact [1.0,1.0,2.0,6.0,24.0] ...> take 5 facBad [1.0 ERROR - Control stack overflow Thanks

On 2003-04-13 at 09:55EDT Eileen Head wrote:
I have two version of factorial as follows:
fac = 1.0: zipWith (*) [1.0 ..] fac
fact = 1.0: [ f | f <- zipWith (*) [1.. ] fact ]
Could some explain why does facBad run out of stack memory while fact work fine?
i.e.
... > take 5 fact [1.0,1.0,2.0,6.0,24.0] ...> take 5 facBad [1.0 ERROR - Control stack overflow
Both fac and fact work fine for me in both ghci and hugs. Are you sure you sent us the right facBad? Jón -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk
participants (2)
-
Eileen Head
-
Jon Fairbairn