Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created June 8, 2014 17:30
Show Gist options
  • Save trikitrok/045cf35c679b2456eedf to your computer and use it in GitHub Desktop.
Save trikitrok/045cf35c679b2456eedf to your computer and use it in GitHub Desktop.
(ns fizz_buzz.core)
(defn fizz-buzz [coll]
(let
[fizz-buzz-number
(fn [num]
(let [is-multiple-of? (fn [n] (= 0 (rem num n)))
a-multiple-of-3 (is-multiple-of? 3)
a-multiple-of-5 (is-multiple-of? 5)
a-multiple-of-both (and a-multiple-of-3
a-multiple-of-5)]
(cond
a-multiple-of-both "FizzBuzz"
a-multiple-of-3 "Fizz"
a-multiple-of-5 "Buzz"
:else (str num))))]
(clojure.string/join
\space
(map fizz-buzz-number coll))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment