Create a gist now

Instantly share code, notes, and snippets.

A fizzbuzz implementation that produces a lazy list of results.
(defn fizzbuzz-seq
[]
(letfn [(nil-prefix [n s]
(concat (take n (cycle [nil])) [s]))]
(map #(let [s (or %4 %2 %3 (inc %1))] s)
(range)
(cycle (nil-prefix 2 "Fizz"))
(cycle (nil-prefix 4 "Buzz"))
(cycle (nil-prefix 14 "FizzBuzz")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment