Created
November 19, 2011 02:23
-
-
Save indiebrain/1378338 to your computer and use it in GitHub Desktop.
A lazy sequence implementation of the fizzbuzz problem.
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
(ns fizzbuzz.core) | |
(defn divisible [x n] | |
(if (= 0 (mod x n)) | |
:true)) | |
(defn nth-fizzbuzz-term [n] | |
(cond (and (divisible n 3) (divisible n 5)) :fizzbuzz | |
(divisible n 3) :fizz | |
(divisible n 5) :buzz | |
:else n)) | |
(defn fizzbuzz [x] | |
(lazy-seq (map nth-fizzbuzz-term (range 1 (inc x))))) | |
;; Example Usage | |
;; > (take 10 (drop 100000000 (fizzbuzz.core/fizzbuzz 1500000000))) | |
;; (100000001 :fizz 100000003 100000004 :fizzbuzz 100000006 100000007 :fizz 100000009 :buzz) |
Author
indiebrain
commented
Nov 22, 2011
via email
see what I did there?
…---
Aaron Kuehler
On Nov 22, 2011, at 5:45 PM, Kyle ***@***.*** wrote:
ew you said 'blow your stack.'
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1378338
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment