Giving several functions the same argument
- To: mathgroup at smc.vnet.net
- Subject: [mg109587] Giving several functions the same argument
- From: Simon Pearce <Simon.Pearce at nottingham.ac.uk>
- Date: Fri, 7 May 2010 06:28:13 -0400 (EDT)
Hi Mathgroup,
I have a list of pure functions, which I wish to apply to the same
argument. I can't seem to be able to thread the list of functions over
the argument in a simple way, all the commands like Apply and Map etc
take a single function. I can do it using Table and Part, but it seemed
like there should be a simple command that I'm missing.
For example:
In[1]:= functs = {Sin[#1] &, Cos[#1] &};
In[2]:= functs[x]
Out[2]= {Sin[#1] &, Cos[#1] &}[x]
I want to get the result {Sin[x],Cos[x]} out, without having to use
something of the form:
In[3]:= Table[functs[[i]][x], {i, 1, 2}]
Out[3]= {Sin[x], Cos[x]}
Which seems like it'd be less efficient when I try and use it on long
lists of functions.
Thanks,
Simon