Created
September 29, 2013 02:03
-
-
Save amscotti/6748683 to your computer and use it in GitHub Desktop.
Example of pattern matching in Elixir
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
defmodule Factorial do | |
def of(0), do: 1 | |
def of(n), do: n * of(n-1) | |
end | |
IO.inspect Factorial.of(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment