This is excellent, I was just working out something similar myself. The version using an atom is not idiomatic Clojure, and isn't a translation of the Haskell version either.
On Thursday, February 12, 2015 at 4:30:02 PM UTC-8, Armando Blancas wrote: > > Jorge, I tried this on 1.6 and seemed to work: > > (def primes > (cons 2 (for [n (iterate inc 3) :when (prime? primes n)] n))) > > On Thursday, February 12, 2015 at 4:21:45 PM UTC-8, Jorge Marques > Pelizzoni wrote: >> >> Neither did delay help: >> >> (defn primes [] (let [primes' (atom nil)] >> (reset! primes' (delay (cons 2 (filter #(prime? (force >> (deref primes')) %) (drop 3 (range)))))))) >> >> >> Serious this is not a bug? >> >> Em quinta-feira, 12 de fevereiro de 2015 22:14:46 UTC-2, Jorge Marques >> Pelizzoni escreveu: >>> >>> Thanks, Michael, for your analysis and explanation. However not even >>> this worked: >>> >>> (defn primes [] (let [primes' (atom nil)] >>> (lazy-seq (reset! primes' (lazy-seq (cons 2 (lazy-seq >>> (filter #(prime? (deref primes') %) (drop 3 (range)))))))))) >>> >>> >>>>> -- 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.