[Haskell-beginners] Infinite recursion in list comprehension

Silent Leaf silent.leaf0 at gmail.com
Thu May 5 17:57:52 UTC 2016

I succeeded to get it working with n = 2,000,000 at least, through this

primesBelow :: Int -> [Int]
primesBelow max = list
  where list = 2:3:rest
        rest = [ v | k <- [1..(max-1)`div`6], i <- [-1, 1]
                       , let v = 6*k+i, checker v]

the function "checker" (in the list comprehension, as conditional) is using
itself in its definition the variable "list" to generate the test for each
"v" of the list comprehension "rest". I dunno if this kind of recursion
suits you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160505/314e2cca/attachment.html>

More information about the Beginners mailing list