MathGroup Archive 2000

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

Search the Archive

Re: Clear or remove definitions including Subscripts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23130] Re: [mg23116] Clear or remove definitions including Subscripts
  • From: Hartmut Wolf <hwolf at debis.com>
  • Date: Thu, 20 Apr 2000 03:20:49 -0400 (EDT)
  • Organization: debis Systemhaus
  • References: <200004190630.CAA07512@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

SANCHEZ DE LEON, Guillermo schrieb:
> 
> If I write:
> 
> In[1]:= Subscript[a, 11];
> In[2]:= Subscript[a, 12];
> 
> Q1: How I can Clear or Remove the previous definitions?.
> Q2: Is it posible to clear at the same time all definitions with pattern:
> Subscript[a, i] (* i=1,2,..*)
> 
> I wish to avoid using Notation Package
> 

Guillermo,

the values of Subscript[a, ..] are not attached to the symbol "a" but
stored as definitions for the System symbol "Subscript".  So Clear[a]
doesn't do it, and Clear[Subscript] will destroy all subscripted values
for all symbols. Instead use Unset:

In[1]:= Subscript[a, 1] = "one";
	Subscript[a, 2] = "two";
	Subscript[a, 3] = "three";
	Subscript[a, 1, 2] = "both";

In[5]:= ?a

In[6]:= ?Subscript
Subscript[a, 1] = "one"
 
Subscript[a, 2] = "two"
 
Subscript[a, 3] = "three"
 
Subscript[a, 1, 2] = "both"

In[7]:= \!\(a\_3 =. \)

In[8]:= Subscript[a, 3]
Out[8]= \!\(a\_3\)

So a\_3 is now undefined. 
If you want to unset all a\_<<i>> you may do so:

In[9]:= Apply[Function[v, v =. , {HoldFirst}], 
	  Cases[DownValues[Subscript], 
		p:Subscript[a, _] -> Hold[p], {-2}],
	{1}]
Out[9]= {Null, Null}

In[10]:= ?Subscript
Subscript[a, 1, 2] = "both"


Kind regards, Hartmut


  • Prev by Date: Re: A 3D-list-plot problem
  • Next by Date: Gaussian fit
  • Previous by thread: Clear or remove definitions including Subscripts
  • Next by thread: Re: Clear or remove definitions including Subscripts