Created
September 21, 2011 12:18
-
-
Save denlab/1231894 to your computer and use it in GitHub Desktop.
coding-dojo-20110921
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn primes [n] nil | |
(reverse | |
(loop [candidate 2 current n acc []] | |
(if (zero? current) | |
acc | |
(if (every? #(not= 0 (rem candidate %)) acc) | |
(recur (inc candidate) (dec current) (cons candidate acc)) | |
(recur (inc candidate) current acc)))))) | |
(fact | |
(primes 1) => [2] | |
(primes 2) => [2 3] | |
(primes 3) => [2 3 5]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Menfin le décompte des objets intermédiaires quand on utilise un algo naïf c'est pas important. Là on est dans une approche parnassienne du code. https://gist.github.com/1236838#comments
"Le code pour le code."