Functions with same name and varying arity using apply
Thu Jan 20 00:03:56 CET 2011
Hi there, is the following possible in Erlang? If I use the following code:
foo(A) -> A.
foo(A, B) -> A + B.
bar(_, ) -> ;
bar(F, [X|Xs]) -> [apply(test, F, X) | bar(F, Xs)].
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
More information about the erlang-questions