Stabilise benchmarks wrt. GC
[nofib.git] / imaginary / primes / Main.hs
1
2 import Control.Monad (forM_)
3 import System.Environment
4
5 isdivs :: Int -> Int -> Bool
6 isdivs n x = mod x n /= 0
7
8 the_filter :: [Int] -> [Int]
9 the_filter (n:ns) = filter (isdivs n) ns
10
11 prime :: Int -> Int
12 prime n = map head (iterate the_filter [2..n*n]) !! n
13
14 main = forM_ [1..100] $ const $ do
15 [arg] <- getArgs
16 print $ prime (read arg)