Last active
June 30, 2024 14:37
-
-
Save trikitrok/74f8cdb860b7b1b70571 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fizz_buzz.core) | |
(defn fizz-buzz-number [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)))) | |
(defn fizz-buzz [coll] | |
(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