Skip to content

Instantly share code, notes, and snippets.

@nimish-mehta
Created December 20, 2016 13:19
Show Gist options
  • Save nimish-mehta/3dbfceb280255c16d7706cde23fdbb00 to your computer and use it in GitHub Desktop.
Save nimish-mehta/3dbfceb280255c16d7706cde23fdbb00 to your computer and use it in GitHub Desktop.
Recursively calling anonymous functions in elixir
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