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>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
f is a function, in the sense that when Mathematica sees it with an argument--f[2], 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[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]][2] 2 a[[3]][3] 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[[1]][2] > 4 >a[[2]][[2] > f/2[2] >I know I'm missing something fundamental. >Cheers, Scott > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- Forcing Argument Evaluation
- From: "Scott Guthery" <sguthery@mobile-mind.com>
- Forcing Argument Evaluation