Created
December 20, 2016 13:19
-
-
Save nimish-mehta/3dbfceb280255c16d7706cde23fdbb00 to your computer and use it in GitHub Desktop.
Recursively calling anonymous functions in elixir
This file contains hidden or 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
factorial = fn (x) -> | |
calc_factorial = fn | |
(_, 0) -> 1 | |
(calc_fn, n) -> n * calc_fn.(calc_fn, n - 1) | |
end | |
calc_factorial.(calc_factorial, x) | |
end | |
IO.inspect factorial.(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment