Skip to content

Instantly share code, notes, and snippets.

@andrewrlee
Last active August 29, 2015 14:01
Show Gist options
  • Save andrewrlee/db89939ed433a48651a4 to your computer and use it in GitHub Desktop.
Save andrewrlee/db89939ed433a48651a4 to your computer and use it in GitHub Desktop.
Clojure fizzbuzz
(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