Last active
December 12, 2015 06:29
-
-
Save ponzao/4729242 to your computer and use it in GitHub Desktop.
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
;; without numbers | |
(def fizzbuzz | |
(let [fizz (cycle [nil nil "fizz"]) | |
buzz (cycle [nil nil nil nil "buzz"])] | |
(remove empty? (map str fizz buzz)))) | |
;; with numbers | |
(defn fizzbuzz | |
[n] | |
(let [xs (range 1 (inc n)) | |
fizz (cycle [nil nil "fizz"]) | |
buzz (cycle [nil nil nil nil "buzz"])] | |
(map (fn [x s1 s2] | |
(if (or s1 s2) | |
(str s1 s2) | |
x)) | |
xs fizz buzz))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment