MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Giving several functions the same argument


On 5/7/10 at 6:28 AM, Simon.Pearce at nottingham.ac.uk (Simon Pearce)
wrote:

>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,

Use Map, i.e.

In[4]:= #[x]&/@ functs

Out[4]= {Sin[x], Cos[x]}



  • Prev by Date: Re: Easy question, please help to run a function n times
  • Next by Date: PlotLegend Bug?
  • Previous by thread: Re: Giving several functions the same argument
  • Next by thread: Re: Giving several functions the same argument