Re: Finding primes using a primes map with Haskell and Hugs98

2000-12-17 Thread Adrian Hey
On Sun 17 Dec, Adrian Hey wrote: > You can use a variation of this algorithm with lazy lists.. > > primes = 2:(get_primes [3,5..]) > get_primes (x:xs) = x:(get_primes (strike (x+x) (x*x) xs)) ^^^ Whoops,

RE: Finding primes using a primes map with Haskell and Hugs98

2000-12-17 Thread Elke Kasimir
Your algorithm seems to be based on the following idea: calculate the non-primes and derive the primes from them by calculating the set difference of the natural numbers and the non-primes. A naive implementation of this idea can be found as primes' in the attachached file. The function us

Problem with functional dependencies

2000-12-17 Thread Marcin 'Qrczak' Kowalczyk
The following module is rejected by both ghc -fglasgow-exts -fallow-undecidable-instances and hugs -98 class HasFoo a foo | a -> foo where foo :: a -> foo data A = A Int data B = B A instance HasFoo A Int where

Re: Finding primes using a primes map with Haskell and Hugs98

2000-12-17 Thread Adrian Hey
On Fri 15 Dec, Shlomi Fish wrote: > There is a different algorithm which keeps a boolean map which tells whether > the number at that position is prime or not. At start it is initialized to all > trues. The algorithm iterates over all the numbers from 2 to the square root > of the desired bound, a