Why is there a unit argument to the haskellwiki prime numbers implementations
What the title says.
Example excerpted from the haskellwiki prime numbers p开发者_运维百科age:
{-# OPTIONS_GHC -O2 -fno-cse #-}
primesTME () = 2 : ([3,5..] `minus` join [[p*p,p*p+2*p..] | p <- primes'])
where
....
What is the purpose of the ()
argument? The code seems to work fine without it. My guess is that it has the effect of forcing the list of primes to be recalculated for each application, but why would that be desirable?
Would you want to have a persistent list of 1000000+ primes in the Memory that you only need at a later point and that eats 8MB of RAM? If not, use a dummy arg and some flags to avoid sharing.
精彩评论