
1 Mar
2008
1 Mar
'08
11:45 a.m.
Milos Hasan wrote:
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?
sum is not tail-recursive. Sometimes, GHCs strictness analyzer is able to optimize that away. Regards, apfelmus