Re: Converting a list to arguments for a function --- How?
- To: mathgroup at smc.vnet.net
- Subject: [mg118671] Re: Converting a list to arguments for a function --- How?
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sat, 7 May 2011 07:30:04 -0400 (EDT)
Method:
f[x_,y_,z_] := x^2 = y z
lis = {4,1,2};
Apply[f, lis]
(* abbreviated form: *_
f @@ lis
Explanation:
Head[lis]
List
Apply[func,lis]
func[4, 1, 2]
On 5/6/2011 7:24 AM, 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?
>
>
>
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305