[erlang-questions] re cursive fun()
deepblue_other
cktgatb@REDACTED
Sun Oct 5 18:07:57 CEST 2008
so definitely no named nested functions?
Zvi wrote:
>
> Otherwise, than passing the Fun as argument to itself, one can implement
> recursive functions, using code, like this:
>
> fact(0) -> 1;
> fact(N) when N>0 ->
> {M,F,_A} = element(2,process_info(self(),current_function)),
> N * {M,F}(N-1).
>
> But this doesn't work for funs, if there are was something like:
>
> Fact = fun(0) -> 1;
> (N) when N>0 ->
> Fun = element(2,process_info(self(),current_fun)),
> N * Fun(N-1).
>
> Zvi
>
>
> deepblue_other wrote:
>>
>> hello
>> I have this going on
>>
>> FunVar =
>> fun() ->
>> ...
>> FunVar()
>> end.
>>
>> so the compiler is complaining that FunVar is unbound at the place where
>> its being used inside fun(); this makes sense, however Im wondering how
>> to make this into a recursive function since there's no name to reference
>> the function with.
>>
>> thanks
>>
>
>
--
View this message in context: http://www.nabble.com/recursive-fun%28%29-tp19820386p19826090.html
Sent from the Erlang Questions mailing list archive at Nabble.com.
More information about the erlang-questions
mailing list