Skip to content

Instantly share code, notes, and snippets.

@abedra
Created November 29, 2011 21:34
Show Gist options
  • Save abedra/1406613 to your computer and use it in GitHub Desktop.
Save abedra/1406613 to your computer and use it in GitHub Desktop.
(use 'clojure.test)
(defn fizzbuzz [coll]
(map (fn [num]
(cond
(and (zero? (mod num 3)) (zero? (mod num 5))) "FizzBuzz"
(zero? (mod num 3)) "Fizz"
(zero? (mod num 5)) "Buzz"
:else num))
coll))
(deftest test-fizzbuzz
(is (= '(1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" 11 "Fizz" 13 14 "FizzBuzz" 16 17 "Fizz" 19 "Buzz")
(fizzbuzz (range 1 21)))))
(run-tests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment