# Unwrapping a list when invoking a function [duplicate]

The minimal working example of my problem is as follows:

l = {1, 2, 3, 4}
f[a_, b_, c_, d_] = a + b + c + d


Now, I'd like to evaluate

f[l[[1]],l[[2]],l[[3]],l[[4]]]


, but with a syntax like f[Unwrap[l]].

I don't have access to the code of 'f', and I can't simply change the way it is defined to accept a list

Basically, I am missing the functionality present in Python with the *,

l=[0,1,2,3]
def f(a,b,c,d):
return a+b+c+d
print f(*l)

-

## marked as duplicate by rm -rf♦Jul 8 '13 at 18:48

list = {1, 2, 3, 4}; f[a_, b_, c_, d_] = a + b + c + d; f[Sequence @@ list] ? –  belisarius Jul 8 '13 at 18:36
f@@l does the trick ;) (python pah!) –  Stefan Jul 8 '13 at 18:37
Related question. –  Leonid Shifrin Jul 8 '13 at 18:49
@rm-fr If this link should be considered canonical Q&A maybe You will put there Operate based answer. –  Kuba Jul 8 '13 at 19:15

There are two ways of doing this that are mostly equivalent. First,

f[ Sequence @@ l ]
(* 10 *)


But, the use of Sequence is to many characters, in my opinion, and there is a better way. Essentially, the notation @@ is shorthand for the function Apply which replaces the Head of an expression with another head. In the prior case, Sequence replaced the head List which was then passed into f. But, this can be used directly,

f @@ l
(* 10 *)


which replaces the head List with f.

-

and the third one (thanks to rm -rf)

l = {a, b, c, s};
Operate[f &, l]

f[a, b, c, s]


but in such simple case f@@l is what I use.

-