Last active
December 5, 2017 00:18
-
-
Save boogie666/552d9fcc8ac1942395ec233ac68f60ad to your computer and use it in GitHub Desktop.
Lazy Functional FizzBuzz in Clojure
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
(ns fizzbuzz.core) | |
(defn str-max [a b] | |
(if (<= (compare a b) 0) b a)) | |
(def fizzes (cycle ["" "" "fizz"])) | |
(def buzzes (cycle ["" "" "" "" "buzz"])) | |
(def numbers (sequence (comp (map inc) (map str)) (range))) | |
(def pattern (map str fizzes buzzes)) | |
(def fizzbuzz (map str-max numbers pattern)) | |
(doseq [x (take 100 fizzbuzz)] (println x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment