Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Disappearing variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13785] Re: Disappearing variables
  • From: "Allan Hayes" <hay at haystack.demon.cc.uk>
  • Date: Fri, 28 Aug 1998 04:18:13 -0400
  • References: <6rr9u0$15b@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

nobody at News.Dal.Ca wrote in message <6rr9u0$15b at smc.vnet.net>...
>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[1]:= f:=x=123;
>In[2]:=f
>Out[2]:=123
>In[3]:=x
>Out[3]:=123        ** x exists
>In[4]:=Remove[x];
>In[5]:=f
>Out[5]:=123  ** f seems to work
>In[6]:=x
>Out[6]:=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?
>
>Vilis Nams
>
>

Vilis,
Let's look at the assignments that are stored:

f:=x=123;

?f

"Global`f"
f := x = 123

Remove[x]

?f

"Global`f"
f := Removed["x"] = 123

?x
Information::notfound: Symbol x not found."

So, f still evaluates with output 123 but it does not restore the
assignment x=123 nor recreate x; and i is it allowed to assign
Remove["x]" = 123.

Removed["x"]

Removed["x"]


------------------------------------------------------------- Allan
Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642




  • Prev by Date: Automatic Backup of Notebooks?
  • Next by Date: Re: Problems with Read[stream,String] after Read[stream,Number]
  • Previous by thread: Re: Disappearing variables
  • Next by thread: Re: Disappearing variables