[erlang-questions] Functions with same name and varying arity using apply
Thu Jan 20 00:31:33 CET 2011
I don't get what you want to do.
From your example I assume that you want to apply a function (in your case addition) to each element of a list?
You could to the same calculation as follows:
However I'm not sure if I got your question and if this is helpful at all.
Am 20.01.2011 um 00:03 schrieb Taylor Venable:
> Hi there, is the following possible in Erlang? If I use the following code:
> %% test.erl
> foo(A) -> A.
> foo(A, B) -> A + B.
> bar(_, ) -> ;
> bar(F, [X|Xs]) -> [apply(test, F, X) | bar(F, Xs)].
> %% END
> 2> test:bar(foo, [, [2,3]]).
> Is there a way to do the same thing without exporting foo/1 and foo/2?
> It seems not with apply/3, but maybe some technique with apply/2, or
> another way? Thanks for any ideas.
> Taylor C. Venable
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
More information about the erlang-questions