开发者

Why is there a unit argument to the haskellwiki prime numbers implementations

开发者 https://www.devze.com 2023-03-29 11:07 出处:网络
What the title says. Example excerpted from the haskellwiki prime numbers p开发者_运维百科age:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消