MathGroup Archive 2001

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

Search the Archive

Re: Re: How to clear OverBar[p]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30245] Re: [mg30199] Re: How to clear OverBar[p]
  • From: BobHanlon at aol.com
  • Date: Fri, 3 Aug 2001 00:56:14 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 2001/8/2 5:05:18 AM, mrMICE.fi at cbs.dk writes:

>Sorry, I have just one more question.
>
>Normally I clear variables before assigning values so no mistakes are made.
>But the
>
>Use Unset
>Overbar[p]
>
>only works when Overbar[p] has assigned a value otherwise you will get
>an
>error/warning. Is there a way to avoid this, like asking if a variable
>is
>already assigned a value.
>

Since you are going to clear it anyway, you can assign it any arbitrary value 
prior to clearing it.

In[1]:=
SetAttributes[myUnset, HoldFirst];

myUnset[x_] := (x = 0; x=.);

OverBar[p] does not have a value:

In[3]:=
OverBar[p]

Out[3]=
OverBar[p]

myUnset does not result in a warning:

In[4]:=
myUnset[OverBar[p]]

Assigning OverBar[p] a value

In[5]:=
OverBar[p] = 5

Out[5]=
5

Verifying the value:

In[6]:=
OverBar[p]

Out[6]=
5

Clearing the value:

In[7]:=
myUnset[OverBar[p]]

Verifying that it is cleared

In[8]:=
OverBar[p]

Out[8]=
OverBar[p]


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Crossing plane and cuboid
  • Next by Date: Calculating Covariance Matrix
  • Previous by thread: Re: How to clear OverBar[p]
  • Next by thread: Re: How to clear OverBar[p]