Re: Applying a list of functions to a single number

*To*: mathgroup at smc.vnet.net*Subject*: [mg74531] Re: Applying a list of functions to a single number*From*: Peter Pein <petsie at dordos.net>*Date*: Sat, 24 Mar 2007 05:21:47 -0500 (EST)*References*: <eu1peu$eu1$1@smc.vnet.net>

siewsk at bp.com schrieb: > Applying a list of functions to a single number > ================================= > > I have > > Square[x_]:=x^2 > Cube[x_]:=x^3 > > I have tried > > In[2]:={Square,Cube} @ 5 > > Out[2]:= {Square,Cube}[5] > > But what I wanted is a list containing > > {25,125} > > Obviously I'm doing this the wrong way. What is the correct way? > > two of them are: Cube[x_] = x*(Square[x_] = x^2); Through[{Square, Cube}[5]] {25, 125} #[5]& /@ {Square, Cube} {25, 125}