
17 Apr
2012
17 Apr
'12
4:56 p.m.
I've got the following code, and I'm not sure why the seq seems to be doing nothing. The code should never terminate if the seq were forcing the full evaluation of y. Instead, it runs just fine (though stack overflows if I ask for too many elements of primes). I didn't see anything in the tutorial section of haskell.org that seems to explain this -- pointers to a useful source would be welcome. sieve :: [Int] -> [Int] sieve xs = let ys = filter (\z -> 0 /= z `mod` head xs) xs in seq ys $ head xs:sieve ys primes = sieve [2..] thanks Lee