Skip to content

Instantly share code, notes, and snippets.

@zmaril
Created August 21, 2011 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zmaril/1159955 to your computer and use it in GitHub Desktop.
Save zmaril/1159955 to your computer and use it in GitHub Desktop.
Primes infinite sequence
(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