T)g(vq4nlh#kLTw3)VBjeKym4+1{Py>gkT/[G8a>dvE3xwDG)rx&]4uf3hQ__Tttxx4D{:q']L"z|D
8]exCk6'A6./E=.5#"j=/2_D"Ji+angC
Sender: [EMAIL PROTECTED]
Precedence: bulk
Resent-Date: Tue, 24 Nov 1998 23:14:52 +0000
Resent-From: [EMAIL PROTECTED]
Resent-To: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
I am using ghc 4.00 on i386 Linux:
Linux dahmer.pscico.cs.cmu.edu 2.0.35 #1-GENERIC Thu Sep 3 09:20:31 EDT 1998 i686
unknown
I compiled the following program by
ghc Sieve.hs -o Sieve-h
and ran it on various inputs. It worked for small n, but seg faulted
on larger n:
314 ~/haskell chen@dahmer$ ./Sieve-h 84 > /dev/null
zsh: 8924 segmentation fault ./Sieve-h 84 > /dev/null
module Main (main)
where
import System
primes :: [Int]
primes = sieve [2..]
sieve (p:xs) = p : sieve [ x | x<-xs, x `mod` p /= 0 ]
main =
do
args <- getArgs
main2 args
main2 :: [String] -> IO ()
main2 [arg] = mapM_ print prs
where
num = read arg
prs = take num primes
main2 _ = error "Usage: sieve num\n"
--
Franklin Chen mailto:[EMAIL PROTECTED]
Graduate Student http://www.cs.cmu.edu/~chen/
Computer Science Department Wean Hall 8218
Carnegie Mellon University