Evaluation of Conditional Definitions
- To: mathgroup at smc.vnet.net
- Subject: [mg33808] Evaluation of Conditional Definitions
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 16 Apr 2002 03:52:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Dear MathGroup, I want to make a definition that will apply only if a global variable is set to True. The following works, but only with an original input expression and not on reevaluation of an expression. Clear[g, a, UseDefinition]; g[a] /; UseDefinition == True := 2 UseDefinition = False; expr = g[a] g[a] UseDefinition = True; g[a] 2 But... expr g[a] Why does Mathematica stop before applying the definition to g[a]? I actually want to use this with an UpValue definition but run into the same problem. Clear[f, a, UseDefinition]; a /: f[a] /; UseDefinition == True := 2 UseDefinition = False; expr = f[a] f[a] UseDefinition = True; f[a] 2 expr f[a] David Park djmp at earthlink.net http://home.earthlink.net/~djmp/