Why is this prime test so slow?
问题 This code was taken from the book "Haskell Road to Logic, Math and Programming". It implements sieve of eratosthenes algorithm and solves Project Euler Problem 10. sieve :: [Integer] -> [Integer] sieve (0 : xs) = sieve xs sieve (n : xs) = n : sieve (mark xs 1 n) where mark :: [Integer] -> Integer -> Integer -> [Integer] mark (y:ys) k m | k == m = 0 : (mark ys 1 m) | otherwise = y : (mark ys (k+1) m) primes :: [Integer] primes = sieve [2..] -- Project Euler #10 main = print $ sum $ takeWhile (