[erlang-questions] How to wrap a function of any arity

Ludovic Coquelle lcoquelle@REDACTED
Fri Nov 17 16:46:34 CET 2006


I would like to wrap a function into another which send the the result of
the inner function to some external process.
Let say I have a function called "compute" and a log process "logger": I
want to create a new function with something like:

Log_compute = wrap_fun(compute, logger).

wrap_fun(Fun, Pid) ->
    fun(AllArgs) ->
        Res = Fun(AllArgs),
        Pid ! Res
    end.

But I don't know how to do that with a function of any arity (the code above
work only for function of arity 1).
Is this do-able? if not, how should I do?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061117/793945c5/attachment.htm>


More information about the erlang-questions mailing list