Re: Turning the elements of a list into the arguments of a function.
- To: mathgroup at smc.vnet.net
 - Subject: [mg8873] Re: [mg8827] Turning the elements of a list into the arguments of a function.
 - From: Allan Hayes <hay at haystack.demon.co.uk>
 - Date: Tue, 30 Sep 1997 20:16:38 -0400
 - Sender: owner-wri-mathgroup at wolfram.com
 
"Scott Morrison" <scott at morrison.fl.net.au>
[mg8827] Turning the elements of a list into the arguments of a function.
writes:
> I need to be able to convert
> f[q, {{a,b}, {c,d}}] into f[q, {a,b}, {c,d}]
> What I am actually trying to do is use FindMinimum with a  
variable > number of variables, so I tried FindMinimum[expr,  
Table[{g[i], 0}, > {i, 1, n}]...
Scott
Two ideas for the first problem:
FlattenAt[f[q, {{a,b}, {c,d}}],-1]
	f[q,{a,b},{c,d}]
MapAt[Apply[Sequence@@#]&,f[q, {{a,b}, {c,d}}],-1]
	f[q,{a,b}[c,d]]
The second problem is a little trickier, since you need to make  
FindMinimum evaluate the last entry before checking that the input  
is as expected. Here is one way		
FindMinimum[x[1]^2 +x[2]^2, Evaluate[Sequence@@Table[{x[i],1},{i,1,2}]]]
{3.549874073494553*^-30,
  {x[1] -> 1.332267629550187*^-15,
   x[2] -> 1.332267629550187*^-15}}
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK