3 ms·
Here’s an okay Clojure version. Using (clojure.string/join “\n” coll) would be more idiomatic. And there’s probably a concise way to leave the nils in the seq
by filoeleven 7y ago
Here’s an okay Clojure version.
Using (clojure.string/join “\n” coll) would be more idiomatic. And there’s probably a concise way to leave the nils in the sequence alone instead of mapping str—that would change the “if” into an “or”, which is closer to the original solution.
(defn fizzbuzz [n]
(doall (map
#(println (if (seq %1) %1 %2))
(map str (cycle [nil nil "fizz"])
(cycle [nil nil nil nil "buzz"]))
(range 1 (inc n))))
nil)