
7 Dec
2008
7 Dec
'08
9:16 p.m.
Hi, I have a small problem with System.Random.randoms. I need a rather large number of random numbers but the following program consumes a huge amount of memory. I terminated it when it used up more than 2 Gb: module Main where import System.Random n :: Int n = maxBound main = do g <- getStdGen print $ length $ take n $ ((randoms g)::[Int]) On the other hand using take n $ [1..] it runs in constant space. Am I doing something wrong? Or should I just abandon randoms and use the more primitive functions in System.Random? Thanks in advance S. Günther