       Re: Forcing Argument Evaluation

• To: mathgroup at smc.vnet.net
• Subject: [mg49873] Re: [mg49848] Forcing Argument Evaluation
• From: DrBob <drbob at bigfoot.com>
• Date: Thu, 5 Aug 2004 09:20:33 -0400 (EDT)
• References: <200408041446.KAA20125@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```f is a function, in the sense that when Mathematica sees it with an argument--f, for instance--your definition matches that pattern, so Mathematica can substitute 2 for x in the right-hand side and get 4.

But f/2 doesn't match the pattern, so your definition doesn't take effect.

If you want the elements of "a" to be functions, you can do this:

f[x_] := x^2
a = {f, f[#1]/2 & , Function[y, f[y]/2]};
a[]
2

a[]
9/2

Here's a more complicated example:

a = NestList[Function[y, Evaluate[#1[y]^3/2]] & , f, 3]
{f, Function[y, y^6/2],
Function[y, y^18/16],
Function[y, y^54/8192]}

Last[a][y]
y^54/8192

Bobby

On Wed, 4 Aug 2004 10:46:25 -0400 (EDT), Scott Guthery <sguthery at mobile-mind.com> wrote:

> f[x_] := x^2;
> a = {f,f/2};
>a[]
> 4
>a[][
> f/2
>I know I'm missing something fundamental.
>Cheers, Scott
>
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: Asymmetric quadratic coefficient problem
• Next by Date: Binomial ratio expectation
• Previous by thread: Re: Forcing Argument Evaluation
• Next by thread: Re: Forcing Argument Evaluation