Created
August 21, 2011 01:29
-
-
Save zmaril/1159955 to your computer and use it in GitHub Desktop.
Primes infinite sequence
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 [] | |
(map #(last (last %)) | |
(iterate | |
(fn [[n prime-list]] | |
(if (every? false? (map #(= 0 (mod n %)) prime-list)) | |
[(inc n) (conj prime-list n)] | |
(recur [(inc n) prime-list]))) | |
[3 [2]]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment