Simpler primes example 
11 Mar 2012, 23:57
tom hall (1 post) 
Section 3.3, you coul avoid using the factor ring as I think it’s non obvious whats going on (def primessimple (concat [2 3 5 7] (lazyseq (let [primesfrom (fn primesfrom [n] (if (some #(zero? (rem n %)) (takewhile #(<= (* % %) n) primessimple)) (recur (+ n 1)) (lazyseq (cons n (primesfrom (+ n 1))))))] (primesfrom 11))))) 
01 Apr 2012, 04:32
Gregg Williams (4 posts) 
I agree! I’ve been writing Clojure code for two years and I can’t figure out how this code works. (I’m reading the beta 5 book, page 71.) I’m rereading the book (I also have the original Programming Clojure book) from the start, and this code is much harder than all the other code so far. Without some qualification in the text (e.g., “Don’t worry about not understanding this…”), this is very jarring. 
11 Dec 2012, 21:59
Erik Pischel (1 post) 
On a freshly installed leiningen, it doesn’t even compile:

19 May 2014, 09:10
Peter West (1 post) 
The confusion with the primes example is to do with the “wheel” hardwired cycle. I had no idea what it was doing until I read the paper The Genuine Sieve of Eratostheses. The “wheel” is a generalisation of the removal of multiples of 2 from the test for primes. It is a repeating sequence of offsets from one nonmultiple to the next of the initial set of primes. The basis of the cycle is the set of integers from 1 to the lowest common multiple of the initial set of primes. For example, with an initial set of The following sets are simply incremented by the cycle length;
so The initial set in this case is Because our starting point is always the first candidate following the last of the starting set, we always skip the first increment, which will recur at the beginning of the next cycle. So the wheel starts The same offsets will apply to all subsequent cycles of 210 integers; hence wheel is defined as a cycle on the vector of candidate offsets. 
You must be logged in to comment 