Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created August 19, 2011 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/1156032 to your computer and use it in GitHub Desktop.
Save swannodette/1156032 to your computer and use it in GitHub Desktop.
fizz.clj
(->> (range 1 101)
(map (fn [x]
(let [[a b] [(mod x 3) (mod x 5)]]
(match [a b]
[0 0] "FizzBizz"
[0 _] "Fizz"
[_ 0] "Buzz"
:else (str x))))))
@alandipert
Copy link

; match-e a match that brings its own single-binding let
(->> (range 1 101)
     (map (fn [x]
            (match-e [(mod x 3) (mod x 5)]
                   [0 0] "FizzBizz"
                   [0 _] "Fizz"
                   [_ 0] "Buzz"
                   :else (str x)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment