Skip to content

Instantly share code, notes, and snippets.

@kasacchiful
Created March 15, 2014 14:34
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 kasacchiful/9568218 to your computer and use it in GitHub Desktop.
Save kasacchiful/9568218 to your computer and use it in GitHub Desktop.
NDS#36 で FizzBuzz 書いた内容
# 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