[erlang-questions] Convert atom and arity into fun

Bjorn Gustavsson <>
Tue Sep 9 13:58:55 CEST 2008

2008/9/8 Edwin Fine <>

> I had this exact issue last night, and this is something like what I did
> because I knew in advance what the arities would be (for better or worse,
> mf_to_fun1(M, F) ->
>     fun(X) -> M:F(X) end.
> mf_to_fun2(M, F) ->
>     fun(X,Y) -> M:F(X,Y) end.
> Ugly but it got the job done. It would be really nice if we could just use
> fun M:F/A, with all these being variables. Surely it can't be a big step
> beyond apply(M, F, [Args])?

There is an undocumented BIF that can be called like this

erlang:make_fun(Mod, Name, Arity)

to create a fun.


Björn Gustavsson, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080909/1f69c168/attachment.html>

More information about the erlang-questions mailing list