Last active
August 29, 2015 14:09
-
-
Save defndaines/dafeec2edb785cbf268b to your computer and use it in GitHub Desktop.
Unconditional Fizz Buzz
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
; Inspired by https://twitter.com/gigasquid/status/530699466891067392 ... | |
; An implementation of the Fizz Buzz Kata with no conditionals. | |
(defn fb-gen | |
[step value] | |
(into (sorted-map) (zipmap (range step 101 step) (repeat value)))) | |
(def nums (into (sorted-map) (zipmap (range 1 101) (range 1 101)))) | |
(def threes (fb-gen 3 "fizz")) | |
(def fives (fb-gen 5 "buzz")) | |
(def fifteens (fb-gen 15 "fizzbuzz")) | |
(doseq [n (vals (merge nums threes fives fifteens))] | |
(println n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of all the other Clojure FizzBuzz without Conditionals, I think that your solution is the clearest and avoids conditionals fully. I only came up with one dealing with hash maps and the default return value.