Last active
August 29, 2015 14:01
-
-
Save andrewrlee/db89939ed433a48651a4 to your computer and use it in GitHub Desktop.
Clojure fizzbuzz
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 | |
(:gen-class)) | |
(defn fizzbuzzify[x] | |
"Get fizzbuzz result for a specific number." | |
(cond | |
(zero? (mod x 15)) "fizzbuzz" | |
(zero? (mod x 3 )) "fizz" | |
(zero? (mod x 5 )) "buzz" | |
:else (str x ))) | |
(defn -main | |
"Apply fizzbuzz to all the numbers from 1 to 30 inclusive." | |
[& args] | |
(doseq [result (map fizzbuzzify (range 1 31) )] (println result ))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment