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

19 Jun
2003
19 Jun
'03
10:19 p.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.
8005
Age (days ago)
8005
Last active (days ago)
0 comments
1 participants
participants (1)
-
oleg@pobox.com