Created
June 24, 2013 19:58
-
-
Save gnab/5853050 to your computer and use it in GitHub Desktop.
FizzBuzz solved using condp function
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 FizzBuzz | |
"Returns 'Fizz', 'Buzz' or 'FizzBuzz' if n is divisible by | |
3, 5 or both, respectively, or else just n." | |
[n] | |
(condp #(zero? (mod %2 %1)) n | |
15 "FizzBuzz" | |
3 "Fizz" | |
5 "Buzz" | |
(str n))) | |
(->> | |
(range 1 16) | |
(map FizzBuzz) | |
(println)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment