Generating Primes and the O'Neill paper

James Aimonetti <>
Wed Dec 16 20:09:23 CET 2009


I have been working the Project Euler problems and wanted to see what 
the list thought about my implementation of a prime number generator 
that is based off the Melissa O'Neill paper[1]. I also used a lazy list 
idea from one of Joe Armstrong's suggestions[2] concerning a Euler 
problem. My implementation uses the priority queue (page 7 of the PDF), 
and I'm using a skew heap I found[3] on this list to accomplish that, 
which I modified to handle key-value pairs instead of just keys.

I made a pastie[4] to view the code.

I tried to stay true to the Haskell version in the paper but had to 
modify some parts. I don't know Haskell so I easily could have lost 
something in the translation.

Oh, the function is called queue because I was playing with other 
methods, like the unfaithful sieve, but I've only included the queue/1 
in the pastie. I am going to try the wheel and other optimizations 
talked about in the paper, but wanted a sanity check from the gurus that 
my Erlang is decent and the implementation isn't totally bunk.

Thanks in advance for any advice or corrections.

[1] - http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
[2] - http://www.erlang.org/cgi-bin/ezmlm-cgi?4:mss:177:khdaceipfabbicmifdhf
[3] - 
http://www.erlang.org/pipermail/erlang-questions/2007-August/028769.html
[4] - http://pastie.org/746050

-- 
James Aimonetti
mobile: 314.809.6307
work: 540.459.2220
email: 
website: http://jamesaimonetti.com



More information about the erlang-questions mailing list