Fizzbuzz in Elixir

Elixir is a beautiful language. Among its strength is its powerful pattern matching system which allows one to write very declarative, elegant code. FizzBuzz is a trivial problem often presented to new programmers or interviewees to determine baseline programming ability. Here is a solution Elixir:

defmodule FizzBuzz do
  def fizz do
    |> Enum.each(&IO.puts/1)

  defp buzz(i) when rem(i, 15) == 0, do: "FizzBuzz"
  defp buzz(i) when rem(i, 5)  == 0, do: "Buzz"
  defp buzz(i) when rem(i, 3)  == 0, do: "Fizz"
  defp buzz(i),                      do: Integer.to_string(i)

This kind of declarative syntax frequently makes handling changes in business requirements as easy as adding an additional definition for a function.