Re: Disappearing variables
- To: mathgroup at smc.vnet.net
- Subject: [mg13801] Re: [mg13759] Disappearing variables
- From: BobHanlon at aol.com
- Date: Fri, 28 Aug 1998 04:18:24 -0400
- Sender: owner-wri-mathgroup at wolfram.com
f:=x=123 ?f "Global`f" f := x = 123 f 123 x 123 Remove[x] Removing x changed the definition for f: ?f "Global`f" f := Removed["x"] = 123 f 123 x is no longer in the definition of f; consequently, the call for f did not re-assign the value to x x x Bob Hanlon In a message dated 8/24/98 6:51:01 AM, nobody at News.Dal.Ca wrote: >I want to to define a variable inside a function, as follows: f:=x=123; >Whenever I run f, x should be given the value of 123, and if x doesn't >exist, it should be created. However: > >In:= f:=x=123; >In:=f >Out:=123 >In:=x >Out:=123 ** x exists >In:=Remove[x]; >In:=f >Out:=123 ** f seems to work >In:=x >Out:=x ** x doesn't exist anymore, even though f worked > >It seems like x is created when I initially define f, whereas since f is >SetDelayed, x should be created when I run f. Does anyone know why x >is not created when I run f?