MathGroup Archive 1998

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

Search the Archive

Re: Disappearing variables

  • To: mathgroup at
  • Subject: [mg13785] Re: Disappearing variables
  • From: "Allan Hayes" <hay at>
  • Date: Fri, 28 Aug 1998 04:18:13 -0400
  • References: <6rr9u0$>
  • Sender: owner-wri-mathgroup at

nobody at News.Dal.Ca wrote in message <6rr9u0$15b at>...
>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;
>Out[3]:=123        ** x exists
>Out[5]:=123  ** f seems to work
>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

Let's look at the assignments that are stored:



f := x = 123



f := Removed["x"] = 123

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.



------------------------------------------------------------- Allan
Training and Consulting
Leicester UK
hay at
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