Created
March 15, 2014 14:34
-
-
Save kasacchiful/9568218 to your computer and use it in GitHub Desktop.
NDS#36 で FizzBuzz 書いた内容
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class Integer | |
def fizzbuzz | |
mod_n_zero = ->(n,i){ i % n == 0 }.curry | |
case self | |
when mod_n_zero[15] then "FizzBuzz" | |
when mod_n_zero[3] then "Fizz" | |
when mod_n_zero[5] then "Buzz" | |
else self | |
end | |
end | |
end | |
p [*1..100].map {|i| i.fizzbuzz } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment