Generating Primes and the O'Neill paper
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. I also used a lazy list
idea from one of Joe Armstrong's suggestions concerning a Euler
problem. My implementation uses the priority queue (page 7 of the PDF),
and I'm using a skew heap I found on this list to accomplish that,
which I modified to handle key-value pairs instead of just keys.
I made a pastie 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.
 - http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
 - http://www.erlang.org/cgi-bin/ezmlm-cgi?4:mss:177:khdaceipfabbicmifdhf
 - http://pastie.org/746050
More information about the erlang-questions