Skip to content

Instantly share code, notes, and snippets.

@defndaines
Last active August 29, 2015 14:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defndaines/dafeec2edb785cbf268b to your computer and use it in GitHub Desktop.
Save defndaines/dafeec2edb785cbf268b to your computer and use it in GitHub Desktop.
Unconditional Fizz Buzz
; 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))
@ClashTheBunny
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment