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 primes-simple (concat [2 3 5 7] (lazy-seq (let [primes-from (fn primes-from [n] (if (some #(zero? (rem n %)) (take-while #(<= (* % %) n) primes-simple)) (recur (+ n 1)) (lazy-seq (cons n (primes-from (+ n 1))))))] (primes-from 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:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: primes in this context, compiling:(NO_SOURCE_PAT H:8) RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:170)

  You must be logged in to comment