Re: Converting a list to arguments for a function --- How?
- To: mathgroup at smc.vnet.net
- Subject: [mg118685] Re: Converting a list to arguments for a function --- How?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 7 May 2011 07:32:37 -0400 (EDT)
On 5/6/11 at 7:24 AM, vs at it.uu.se (Virgil Stokes) wrote: >Suppose I have a list, >list = {4,1,1} >and I wish to use it as follows >f[4,1,1] >Is there a simple way (without looping through the elements list) to >transfer the elements of list to the arguments for f? Use Apply (@@) for example: In[1]:= f[x_, y_, z_] := x^2 + y^2 + z^2 In[2]:= f @@ {4, 1, 1} Out[2]= 18 or In[3]:= Apply[f, {4, 1, 1}] Out[3]= 18