6 ms·
Like this? (defn any-mod-cycle-buzz "Given a number and a sequence of words mapping to prime factors, either return the corresponding word-version for
by adityaathalye 4y ago
Like this?
(defn any-mod-cycle-buzz
"Given a number and a sequence of words mapping to prime factors,
either return the corresponding word-version for the number position,
or the number itself, if no prime factor exists.
Basically, the set of words should map to set of prime factors.
We also don't make any assumptions about order of words here. It is up
to the caller to choose whatever sequence they please."
[num & words]
(or (not-empty (reduce str words))
num))
;; invoked as...
(map any-mod-cycle-buzz
(range 1 16)
(cycle [nil nil "Fizz"])
(cycle [nil nil nil nil "Buzz"]))
edit: indentation