-- Interval of numbers:
fromTo :: Int -> Int -> [Int]
fromTo f t | f > t = []
| otherwise = f : fromTo (f+1) t
-- Special case: t is infinite
from :: Int -> [Int]
from f = f : from (f+1)
fromTo' f t = take (t-f+1) (from f)
-- Sieve of Eratosthenes:
sieve :: [Int] -> [Int]
sieve (x:xs) = x : sieve (filter (\y -> mod y x > 0) xs)
-- all primes:
primes :: [Int]
primes = sieve (from 2)