[erlang-questions] anyway to make recursion inside anonymous funs?

Julian Fondren ayrnieu@REDACTED
Fri Mar 30 11:49:32 CEST 2007


For quick (and probably necessarily short-lived) hacks at EShell,
it suffices to use the process dictionary:

1> Fact = case fun (0) -> 1; (N) when N > 0 -> N*(get(factorial))(N-1)
end of F -> put(factorial, F), F end.
#Fun<erl_eval.6.32248033>
2> Fact(5)
120

Cheers,
Julian



More information about the erlang-questions mailing list