[erlang-questions] Convert atom and arity into fun
Fri Sep 5 12:31:18 CEST 2008
On Fri, Sep 5, 2008 at 12:22 PM, Jeroen Koops <> wrote:
> The answer to this question is probably obvious, but I can't find it
> after searching around for a while:
> 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?
> Thanks in advance,
> Jeroen Koops
> erlang-questions mailing list
Check out erlang:apply/3 (it's a BIF). It is described in manual (man erlang).
You can use Module:Function(Arg1, Arg2, ...) where Module and Function
are variables bound to appropriate atoms. Like this:
Module = lists,
Function = flatlength,
[1, 2] = Module:Function(, )
Every minute is to be grasped.
Time waits for nobody.
-- Inscription on a Zen Gong
More information about the erlang-questions