Re: Forcing Argument Evaluation
- To: mathgroup at smc.vnet.net
- Subject: [mg49906] Re: [mg49848] Forcing Argument Evaluation
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 5 Aug 2004 09:22:28 -0400 (EDT)
- References: <200408041446.KAA20125@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 4 Aug 2004, at 16:46, Scott Guthery 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 > > It's the same problem again, which I already once explained. The algebra of functions is not implemented in Mathematica so although f is a function f/2 is not a function. So you can't expect f/2[2] to have return anything. If you really want implement the algebra of fucntions you could do something like this: Unprotect[Times,Plus]; (a_?NumericQ * f_)[x_]:=a f[x] (f_+g_)[x_]:=f[x]+g[x] (f_*g_)[x_]:=f[x]*g[x] Protect[Times,Plus] Now f[x_]:=x^2; a={f,f/2}; a[[2]][2] 2 Andrzej Kozlowski Chiba, Japan http://www.mimuw.edu.pl/~akoz/
- References:
- Forcing Argument Evaluation
- From: "Scott Guthery" <sguthery@mobile-mind.com>
- Forcing Argument Evaluation