[erlang-questions] calling fun() from fun()
Sat Jun 2 17:19:47 CEST 2007
FibI = fun
(X,_) when X<1 -> throw(badarith);
(1,_) -> 1;
(2, _) -> 1;
(X,FibI) -> FibI(X-1,FibI)+FibI(X-2,FibI)
Fib = fun(X) -> FibI(X, FibI) end,
it produce correct result -- 55.
So, you just should pass it to itself, and if you must use one-arg fun (for example, to pass it to somewhere), make additional fun that will call real fun with additional arg.
--- suicide proc near\n call death\n suicide endp
Post sent from http://www.trapexit.org
More information about the erlang-questions