[erlang-questions] String to Function

Vlad Dumitrescu vladdu55@REDACTED
Mon Dec 18 11:51:05 CET 2006


On 12/18/06, Bob Cowdery <Bob.Cowdery@REDACTED> wrote:
> Is there some way to call a function from a string or atom representation, i.e. to call it indirectly when the code does not know at compile time what function will be called.

If for example
    M = lists,
    F = seq,
you can write
    apply(M, F, [1, 5])

The latter is quite expensive and should only be used when the number
of arguments isn't known at compile time.

best regards,

More information about the erlang-questions mailing list