Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
FizzBuzzBeep in hy.
#! bin/hy
(def targets {3 "fizz" 5 "buzz" 7 "beep"})
(defn match [n factors]
(filter (lambda [x] (= 0 (% n x))) factors))
(defn fizzbuzz [n]
(let [[factors (.keys targets)]
[matches (match n factors)]]
(if (not matches)
(str n)
(.join "" (map (lambda [x] (get targets x)) matches)))))
(print (.join ", " (map fizzbuzz (range 1 106))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment