NumberSieves-0.1.2: Number Theoretic Sieves: primes, factorization, and Euler's Totient

Portabilityportable
Stabilityexperimental
Maintainerleon@melding-monads.com
Safe HaskellSafe-Infered

Math.Sieve.ONeill

Description

Incremental primality sieve based on priority queues, described in the paper The Genuine Sieve of Eratosthenes by Melissa O'Neill, Journal of Functional Programming, 19(1), pp95-106, Jan 2009.

http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf

Code is unchanged, other than packaging, from that written by Melissa O'Neill. This version contains optimizations not described in the paper, primarily improving memory consumption.

http://www.cs.hmc.edu/~oneill/code/haskell-primes.zip

Synopsis

Documentation

primes :: Integral a => [a]Source

An infinite stream of primes

sieve :: Integral a => a -> [a] -> [a]Source

The first argument specifies which number to start at, the second argument is a wheel of deltas for skipping composites. For example, primes could be defined as

  2 : 3 : sieve 5 (cycle [2,4])

calcPrimes :: Integral a => () -> [a]Source

An infinite stream of primes

primesToNth :: Integral a => Int -> [a]Source

Returns the first n primes

primesToLimit :: Integral a => a -> [a]Source

Returns primes up to some limit