Skip to content

Instantly share code, notes, and snippets.

@codeincontext
Created September 21, 2013 15:45
Show Gist options
  • Save codeincontext/6651716 to your computer and use it in GitHub Desktop.
Save codeincontext/6651716 to your computer and use it in GitHub Desktop.
My solution to the pragprog fizzbuzz exercise
fizz_or_buzz = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, x) -> "#{x}"
end
Enum.each 10..16, fn n ->
IO.puts fizz_or_buzz.(rem(n, 3), rem(n, 5), n)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment