Last active
August 18, 2022 01:15
-
-
Save viebel/b133efde8669d6c0630ee6895c1797c6 to your computer and use it in GitHub Desktop.
the most elegant implementation of FizzBuzz - without a single if
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 choice [a b] | |
(clojure.string/join (or (seq a) (seq b)))) | |
(defn fizzbuzz [n] | |
(let [fizzes (cycle ["" "" "Fizz"]) | |
buzzes (cycle ["" "" "" "" "Buzz"]) | |
words (map str fizzes buzzes) | |
numbers (map str (rest (range)))] | |
(take n (map max words numbers)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment