So why isn't 4 and any even numbers in the result list? Empty primes' allows everything to pass. We are already beyond this. I've already posted that even this does not work:
(def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 (range)))))) Em sexta-feira, 13 de fevereiro de 2015 00:39:03 UTC-2, Justin Smith escreveu: > > Considering for the sake of argument the possibility that it is a > legitimate bug, and not a result of misusing the language features, it is a > family of bug that will be more common than most, because it reflects a > style of programming that is rare in real Clojure code. > > But it isn't a bug. > > Lazy-seqs don't promise to be "as lazy as possible", and when we step > through the logic of the original code in Michael Blume's post, we can see > why chunking breaks it. Taking for granted that something lazy is realized > with a specific granularity is an error in Clojure (see also lazy-seqs used > inside with-open blocks or db transactions - the opposite error is common, > not being strict enough). > > defn primes [] (let [primes' (atom nil)] > (reset! primes' (cons 2 (filter #(prime? @primes' %) > (drop 3 (range))))))) > > The first time through the above code, primes' will be empty, so the first > chunk of results will all be calculated with an empty list of candidate > divisors. > >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.