andybeak
4/11/2016 - 9:05 AM

Fizzbuzz with no conditional logic

Fizzbuzz with no conditional logic

fizz = fn
  {0, 0, _} -> "FizzBuzz"
  {0, _, _} -> "Fizz"
  {_, 0, _} -> "Buzz"
  {_, _, a} -> "#{a}"
end

foo = fn (n) -> "#{IO.puts(fizz.({rem(n,3), rem(n,5), n}))}" end

for i <- 1..100 do
  foo.(i)
end