[Haskell-cafe] Generating a random list

Milos Hasan mhasan at cs.cornell.edu
Sat Mar 1 04:04:05 EST 2008


So, I did one more experiment, and the following overflows too:

import System.Random
import Data.List

randFloats :: [Float]
randFloats = randoms (mkStdGen 0)

main = print $ sum $ sort $ take 1000000 randFloats

Could it be that Data.List.sort is the culprit that uses O(n) stack 
space here? If so, is this avoidable?

Thanks a lot,
Milos





More information about the Haskell-Cafe mailing list