|
|
|
|
|
by lkrubner
3427 days ago
|
|
Likewise, using "match", I think the Clojure solution for FizzBuzz is very elegant: (doseq [n (range 1 101)]
(println
(match [(mod n 3) (mod n 5)]
[0 0] "FizzBuzz"
[0 _] "Fizz"
[_ 0] "Buzz"
:else n)))
To my mind, this reads much more clearly than if I wrote a bunch of if() statements. |
|
The structure is almost identical. You even have an "else" clause!