|
|
| Author |
Message |
< Erlang ~ Erlang Newbie,"lists:map" like function. |
| Wessam |
Posted: Thu Jul 31, 2008 1:01 pm |
|
|
|
Joined: 31 Jul 2008
Posts: 2
|
Hi everyone,
I have a question that should be impossible to implement in native Erlang.
I want to be able to do something like this:
some_function(Func,[V1,V2]).
Where Func is a fun that is supplied at run time to some_function THEN some_function will do something like this:
Func(V1,V2).
(It will call Func with the list elements as its arguments).
Note that the number of elements in the list is variable.
The user will be able to use it as specified below:
foo(V1,V2,V3)->
V1+V2+V3.
start()->
Func = fun foo/3,
R=some_function(Func,[1,3,5]).
io:format("~p~n",[R]).% will print 9
This is something like "lists:map" but on all list members at once( not on a single list element at a time).
Is there a BIF to do this.
Thanks in advance:). |
Last edited by Wessam on Fri Aug 01, 2008 8:34 am; edited 1 time in total |
|
| Back to top |
|
| michal |
Posted: Fri Aug 01, 2008 7:39 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 44
Location: London
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|