Suppose I have an array

p = {a,b,c,d}

and a function f that takes a variable number of arguments. I want to evaluate


It won't do to type


because this returns the array {f[a],f[b],f[c],f[d]} which is not at all the right thing.

How do I get f to accept the elements of p (as opposed to p itself) as arguments?

Edited to add: Per a request in comments, here is a concrete example. Suppose p={2,3,4}. I would like an expression that returns Multinomial[2,3,4], which is to say 1260. It doesn't work to type Multinomial[p], because this gives {Multinomial[2],Multinomial[3],Multinomial[4]}={1,1,1}, which is not at all the same as 1260.

  • $\begingroup$ Try evaluating p = {p[1], p[2]}, you won't be able to because it will start an endless recursion that will be capped by the recursion limit. $\endgroup$
    – C. E.
    Mar 7, 2014 at 1:05
  • $\begingroup$ Please provide a more concrete example, including the definition of the function 'f'. It is unclear at this point what you're looking for. $\endgroup$
    – ciao
    Mar 7, 2014 at 1:05
  • $\begingroup$ Pickett: Sorry; I chose a bad name for the array. I'm editing to fix this. The problem remains. $\endgroup$
    – WillO
    Mar 7, 2014 at 1:06
  • $\begingroup$ @rasher: How about taking f=Multinomial ? $\endgroup$
    – WillO
    Mar 7, 2014 at 1:07
  • $\begingroup$ @WillO: Please, edit your question to include the function, and what it does vs what you expect (or need). Using f=Multinomial against your updated p definition returns precisely what's expected... $\endgroup$
    – ciao
    Mar 7, 2014 at 1:11

2 Answers 2


This is really easy if you understand the internal form of {a,b,c,d}. Let's look at it:

(* List[a,b,c,d] *)

as you see what you want is not really far away because basically, you only need to replace List with f. This is exactly what Apply (or as operator @@) does:

f @@ p
(* f[a, b, c, d] *)
  • $\begingroup$ This is crystal clear. All I asked for was a solution, but you gave me both a solution and an understanding, so thank you doubly. $\endgroup$
    – WillO
    Mar 7, 2014 at 1:21
  • $\begingroup$ @ halirutan Isn't is nice when someone ask a question about something that Mathematica was beautifully designed to do. $\endgroup$ Mar 7, 2014 at 2:17
  • $\begingroup$ @GeorgeWolfe Indeed and it is even nicer for the user, because it lets him understand some of the mystifying operators like @@ or @@@ very naturally. $\endgroup$
    – halirutan
    Mar 7, 2014 at 2:22
  • $\begingroup$ This does not necessarily answer the question if the function f requires extra parameters. What if I need f[a,b,c,d,n], like in the Join function? There is no other way but appending n to the list? $\endgroup$
    – Dr_Zaszuś
    May 29, 2019 at 15:17
  • $\begingroup$ I.e. anything better than the slightly cryptic Join @@ Join[p, {n}] $\endgroup$
    – Dr_Zaszuś
    May 29, 2019 at 15:33

You question is not very clear.

a = {p[1], p[2], p[3]}

f[x__] := 2 x


(* or *)

f /@ a

(* or *)


yields, e.g. {2 p[1], 2 p[2], 2 p[3]}

Note also I used a for the vector, else recursion...

If you just want to transmute the vector into an argument list:

f[Sequence @@ p]
  • $\begingroup$ I am sorry the question wasn't clear. I don't think your answer helps with the intended question. What I want to get is f[p[1],p[2],p[3]], not {f[p[1],f[p[2]],f[p[3]}. (I've changed the p[1] etc to a,b,c in the question statement.) $\endgroup$
    – WillO
    Mar 7, 2014 at 1:10
  • $\begingroup$ @WillO: see latter part of answer $\endgroup$
    – ciao
    Mar 7, 2014 at 1:13
  • $\begingroup$ That works! Thank you. $\endgroup$
    – WillO
    Mar 7, 2014 at 1:17
  • $\begingroup$ @WillO: Good, note you can also use Apply (or f@@ as shorthand) to do similar, if it fits with your definitions. $\endgroup$
    – ciao
    Mar 7, 2014 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.