       Re: Applying a list of functions to a single number

• To: mathgroup at smc.vnet.net
• Subject: [mg74548] Re: Applying a list of functions to a single number
• From: "dimitris" <dimmechan at yahoo.com>
• Date: Sun, 25 Mar 2007 01:29:34 -0500 (EST)
• References: <eu1peu\$eu1\$1@smc.vnet.net>

```In:=
square[x_] := x^2
cube[x_] := x^3

In:=
Through[{square, cube}]
Out=
{25,125}

In:=
({square[#1], cube[#1]} & )
Out=
{25,125}

In:=
(#1 & ) /@ {square, cube}
Out=
{25,125}

In:=
{square, cube}
Out=
{25,125}

In:=
{square, cube, 5} /. {x_, y_, z_} :> {x[z], y[z]}
Out=
{25,125}

In:=
Flatten[({square[#1], cube[#1]} & ) /@ {5}]
Out=
{25, 125}

In:=
Information[Through]
>From In:=
"Through[p[f1, f2][x]] gives p[f1[x], f2[x]]. Through[expr, h]
performs the transformation wherever h
occurs in the head of expr."
>From In:=
Attributes[Through] = {Protected}

Regards
Dimitris

=CF/=C7 siewsk at bp.com =DD=E3=F1=E1=F8=E5:
> Applying a list of functions to a single number
> =========================
=========
>
> I have
>
> Square[x_]:=x^2
> Cube[x_]:=x^3
>
> I have tried
>
> In:={Square,Cube} @ 5
>
> Out:= {Square,Cube}
>
> But what I wanted is a list containing
>
>  {25,125}
>
> Obviously I'm doing this the wrong way. What is the correct way?

```

• Prev by Date: Re: including part of files ?
• Next by Date: Re: simplifications
• Previous by thread: Re: Applying a list of functions to a single number
• Next by thread: Inverse of arbitrary functions