Created
November 15, 2014 00:20
-
-
Save dfuenzalida/1f07bf2ab807836c767e to your computer and use it in GitHub Desktop.
FizzBuzz in Clojure without conditionals - http://gigasquidsoftware.com/blog/2014/11/13/clojure-fizzbuzz-without-conditionals/
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 fb [n] | |
(take n | |
(map (fn [a b] (get (hash-map a b) "" a)) | |
(map str | |
(cycle ["" "" "Fizz"]) | |
(cycle ["" "" "" "" "Buzz"])) | |
(rest (range))))) | |
;; Usage: | |
;; user=> (fb 20) | |
;; (1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" 11 "Fizz" 13 14 "FizzBuzz" 16 17 "Fizz" 19 "Buzz") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment