Created
February 21, 2012 01:36
-
-
Save sinemetu1/1872843 to your computer and use it in GitHub Desktop.
Lazy-Primes
This file contains hidden or 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 lazy-seq-prime | |
([] | |
(concat [2] (lazy-seq-prime 2 (iterate inc 2)))) | |
([p nums] | |
(let [nnums (filter (fn [x] (pos? (rem x p))) nums) n (first nnums)] | |
(lazy-seq | |
(cons n (lazy-seq-prime n nnums)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment