Created
January 6, 2012 03:02
-
-
Save zerg000000/1568738 to your computer and use it in GitHub Desktop.
A clojure version of fizzbuzz in 5 minutes
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 mod3? [num] (= (mod num 3) 0)) | |
(defn mod5? [num] (= (mod num 5) 0)) | |
(defn fizzbuzz [num] (cond (and (mod3? num) (mod5? num)) "FizzBuzz" | |
(mod5? num) "Buzz" | |
(mod3? num) "Fizz" | |
:else num)) | |
(map fizzbuzz (range 1 101)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment