[erlang-questions] Efficiency is passing a functin

Antoine Koener antoine.koener@REDACTED
Sun Sep 23 08:17:36 CEST 2012


You don't need to export it, if you use it in the same module...

--
Was on the go

On 23 sept. 2012, at 03:37, Michael Truog <mjtruog@REDACTED> wrote:

> On 09/22/2012 05:07 PM, James Rosenblum wrote:
>> 
>> Kind people,
>> 
>> Is there an appreciable difference in these two ways of passing a function?
>> 
>> F = fun(A,B) -> my_function(A,B) end.
>> lists:map(F, Lst)
>> 
>> vs.
>> 
>> -export([my_function/2]).
>> 
>> lists:map(fun my_function/2, Lst)
>> 
> From http://www.erlang.org/doc/efficiency_guide/functions.html#id67199
> "Calls to local or external functions are the fastest kind of calls."
> So, the second solution is best.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120923/d1a8358e/attachment.htm>


More information about the erlang-questions mailing list