How to convert list to a function arguments in Erlang? -


let's have function of arity. , want feed corresponding list of numbers.

obviously, if have f/2 function , list l = [1,2], can this:

f(hd(l), hd(tl(l))). 

but how can make general? think, there should kind of easy conversion list arguments, don't know yet.

look @ apply/2 function. want.

> apply( fun (x,y) -> x+y end, [1,2]). 3 

there apply/3 includes module of function too:

> apply( io, format , [ "~p, ~p", [1,2]]).         1, 2 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -