Re: Evaluation of Conditional Definitions(2)
- To: mathgroup at smc.vnet.net
- Subject: [mg33819] Re: Evaluation of Conditional Definitions(2)
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 19 Apr 2002 02:27:38 -0400 (EDT)
- References: <NDBBJGNHKLMPLILOIPPOCELOCOAA.djmp@earthlink.net>
- Sender: owner-wri-mathgroup at wolfram.com
David,
Here is another way, one that lets us use either Set or SetDelayed.
The statement, from the Help Browser,
- Using Update will never give you incorrect results, although it will slow
down the operation of the system.
though technically correct, looks in need of a little more explanation,
since the result is changed.
Clear[g,a,UseDefinition];
g[a]/;UseDefinition==rue:=2
expr/;(Update[g];True)=g[a]; (*uses Set*)
UseDefinition=False;
expr
g[a]
UseDefinition=True;
expr
2
UseDefinition=False;
expr
g[a]
UseDefinition=True;
expr
2
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565