Ah, primes :-) That was my first foray into Clojure as well. I wrote about it here: http://www.superloopy.io/articles/2014/learning-clojure.html - you might find it interesting: my first attempt wasn't so different from yours.
Stig On Wednesday, 26 November 2014 14:52:44 UTC, Chernyshev Alex wrote: > > (defn not-divisible-by?[num denum] > (not (= (mod num denum) 0))) > > (defn div-nums [denum bound] > (for [x (range 2 bound) :when (not-divisible-by? x denum)] x)) > > (defn divisible? [coll denum] > (empty? (filter #(and (not= denum %) (not(not-divisible-by? denum %))) > coll))) > > (defn generate-primes > "Sieve of Eratosthenes" > [n] > (let [src (div-nums 2 n)] > (cons 2 (for [x src :when (divisible? src x)] x)))) > > > -- 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.