Re: Help: Stack-overflow and tail-recursive functions

20 Jun
2003
20 Jun
'03
2:19 a.m.
It seems the problem is indeed in rmat:
rmat n = listArray ((1,1),(n,n)) $ map ct (randoms (mkStdGen 1) ::[Bool]) where ct True = Unknown ct False = Dead
To be more precise, the problem is in randoms. If you replace rmat with the following rmat n = array ((1,1),(n,n)) $ zipWith (\ind v -> v `seq` (ind,v)) [(i,j) | i<-range, j<-range] $ map ct (randoms (mkStdGen 1) ::[Bool]) where ct True = Unknown ct False = Dead range = [1..n] then
main = putStrLn $ show $ forpaintbdry $ rmat 400
computes without problems (compiled with GHC 5.04.1, no flags). BTW, GHCi didn't have any problem even with the original code.
8052
Age (days ago)
8052
Last active (days ago)
0 comments
1 participants
participants (1)
-
oleg@pobox.com