[erlang-questions] re cursive fun()

Richard Andrews bbmaj7@REDACTED
Sun Oct 5 12:12:16 CEST 2008



> 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. 


Maybe have the fun call a real (recursive) function.

eg.

F(A) ->
    ...
    F(B).

Caller(Data) ->
    ...
    FunVar = fun(A) -> F(A) end,
    ...
    foo:use_fun(FunVar, Data).

--
  Rich


      Make the switch to the world's best email. Get Yahoo!7 Mail! http://au.yahoo.com/y7mail



More information about the erlang-questions mailing list