Skip to content

Instantly share code, notes, and snippets.

@kyleburton
Last active December 10, 2015 11:38
Show Gist options
  • Save kyleburton/4428579 to your computer and use it in GitHub Desktop.
Save kyleburton/4428579 to your computer and use it in GitHub Desktop.
fizz-buzz.clj
;; condition free fizz-buzz solution, based on code from [email protected] to the clojure list
;; uses infinite, lazy-sequences
(let [three (cycle [nil nil "fizz"])
five (cycle [nil nil nil nil "buzz"])]
(defn fizz-buzz []
(map vector (iterate inc 1) three five)))
(doseq [tuple (take 30 (fizz-buzz))]
(println (apply str (interpose " " (filter identity tuple)))))
;; or
(doseq [tuple (take 30 (fizz-buzz))]
(println (clojure.string/join " " (filter identity tuple))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment