Skip to content

Instantly share code, notes, and snippets.

@ponzao
Last active December 12, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponzao/4729242 to your computer and use it in GitHub Desktop.
Save ponzao/4729242 to your computer and use it in GitHub Desktop.
;; without numbers
(def fizzbuzz
(let [fizz (cycle [nil nil "fizz"])
buzz (cycle [nil nil nil nil "buzz"])]
(remove empty? (map str fizz buzz))))
;; with numbers
(defn fizzbuzz
[n]
(let [xs (range 1 (inc n))
fizz (cycle [nil nil "fizz"])
buzz (cycle [nil nil nil nil "buzz"])]
(map (fn [x s1 s2]
(if (or s1 s2)
(str s1 s2)
x))
xs fizz buzz)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment