[erlang-questions] Convert atom and arity into fun

Richard Carlsson <>
Fri Sep 5 12:45:57 CEST 2008


Jeroen Koops wrote:
> Given a function's name as an atom and an arity (for instance as
> returned by module_info(exports)), how can I convert this into a fun
> that I can invoke?

There is currently no immediate way of doing this. If you just want
to call the function, you can use M:F(...) or apply(M,F,[...]). If
you need a fun, to pass it somewhere, you can wrap such a call in a
new fun, like this: F = fun (...) -> M:F(...) end.

    /Richard



More information about the erlang-questions mailing list