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

Raimo Niskanen raimo+erlang-questions@REDACTED
Thu Mar 29 09:27:15 CEST 2007


The standard trick in Erlang is:

    F = fun(This, X) -> receive {P,V} -> P!{X+V}, This(This, X+V) end end,
    F(F, 17).

On Wed, Mar 28, 2007 at 06:03:10PM +0200, VAUCHER Laurent wrote:
> http://en.wikipedia.org/wiki/Anonymous_recursion  ?
> 
> 
> -----Message d'origine-----
> De : erlang-questions-bounces@REDACTED [mailto:erlang-questions-bounces@REDACTED] De la part de June Kim
> Envoyé : 28 March 2007 17:45
> À : erlang-questions@REDACTED
> Objet : [erlang-questions] anyway to make recursion inside anonymous funs?
> 
> "fun" expressions can be used to declare a function. Can it make a recursive call inside?
> 
> That is,
> 
> Can I somehow declare the following with callself, which is an imaginary functionality that calls the anonymous function itself?
> 
> fun(X) -> receive {P,V} -> P!(X+V), callself(X+V) end end.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB




More information about the erlang-questions mailing list