G'day all.
Quoting Dan Weston :
Unless primesUpTo n goes from highest to lowest prime (ending in 2), I
don't see how sharing is possible (in either space or time) between
primesUpTo for different n.
Given that it's a mistake for a library to leak memory, there are
essentially three possibilit
Unless primesUpTo n goes from highest to lowest prime (ending in 2), I
don't see how sharing is possible (in either space or time) between
primesUpTo for different n.
Is it intended that the primes should therefore be listed in descending
order?
a...@spamcop.net wrote:
primes :: [Integer]
G'day all.
Quoting Eugene Kirpichov :
I'd suggest also
primesFrom :: Integer -> [Integer]
This:
primes :: [Integer]
isn't as useful as you might think for a library, because it must, by
definition, leak an uncontrolled amount of memory. This:
primesUpTo :: Integer -> [Integer]
is a bett
On Apr 15, 2009, at 5:27 PM, Adrian Neumann wrote:
I've just uploaded a package with some functions I had lying around.
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Numbers
This package seems to be missing the source file Data/Numbers/
Primes.hs so I couldn't compare it to m
I've just uploaded a package with some functions I had lying around.
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Numbers
Am 14.04.2009 um 14:40 schrieb Niemeijer, R.A.:
Today I happened to need a large list of prime numbers. Obviously
this is a well-known problem, so I figur
For isPrime you might want to implement the AKS test,
http://en.wikipedia.org/wiki/AKS_primality_test
On Tue, Apr 14, 2009 at 3:05 PM, Edward Kmett wrote:
> You might want to start with the Sieve of Atkin:
>
> http://en.wikipedia.org/wiki/Sieve_of_Atkin
>
> -Edward
>
> On Tue, Apr 14, 2009 at 8:4
Edward Kmett wrote:
You might want to start with the Sieve of Atkin:
http://en.wikipedia.org/wiki/Sieve_of_Atkin
Also worth reading _Lazy wheel sieves and spirals of primes_:
http://www.cs.york.ac.uk/ftpdir/pub/colin/jfp97lw.ps.gz
--
Live well,
~wren
_
ot; , haskell-cafe@haskell.org
Sent: Tuesday, April 14, 2009 12:35:19 PM GMT -05:00 US/Canada Eastern
Subject: Re: [Haskell-cafe] Looking for the fastest Haskell primes algorithm
On Tue, Apr 14, 2009 at 2:47 PM, Andrew Wagner wrote:
> Some other ideas for things to put in this package pos
On Tue, Apr 14, 2009 at 2:47 PM, Andrew Wagner wrote:
> Some other ideas for things to put in this package possibly:
> is_prime :: Int -> Bool
I'd also add isProbablePrime using a Miller-Rabin test or somesuch,
for use with large numbers. It'd have to be in a monad which supplies
randomness, of c
You might want to start with the Sieve of Atkin:
http://en.wikipedia.org/wiki/Sieve_of_Atkin
-Edward
On Tue, Apr 14, 2009 at 8:40 AM, Niemeijer, R.A. wrote:
> Today I happened to need a large list of prime numbers. Obviously this is
> a well-known problem, so I figured there would be something
Niemeijer, R.A. wrote:
Since it’s such a common problem I’d say it would be a good idea to add
a package to Hackage that exports
primes :: [Integer]
and hides the ugly implementation details. Data.Numbers.Primes seems a
logical choice for the namespace, but I’m open to suggestions.
Excellen
I'd suggest also
primesFrom :: Integer -> [Integer]
and probably a separate function
nextPrime :: Integer -> Integer
2009/4/14 Andrew Wagner :
> Some other ideas for things to put in this package possibly:
> is_prime :: Int -> Bool
> nth_prime :: Int -> Int -- or Int -> Integer
> prime_factors
Some other ideas for things to put in this package possibly:
is_prime :: Int -> Bool
nth_prime :: Int -> Int -- or Int -> Integer
prime_factors :: Int -> [Int]
I'm assuming there are faster ways of doing the first 2 than by just simply
looking through all of primes. Someone should also look throug
Today I happened to need a large list of prime numbers. Obviously this is a
well-known problem, so I figured there would be something on Hackage that I
could use. Surprisingly, there isn't, or if there is it's not easy to find.
Searching for prime or primes on Hackage reveals nothing. Searching
14 matches
Mail list logo