Re: Clearing selected variables
- To: mathgroup at smc.vnet.net
- Subject: [mg86644] Re: Clearing selected variables
- From: Albert Retey <awnl at arcor.net>
- Date: Sat, 15 Mar 2008 17:45:38 -0500 (EST)
- References: <frg0ef$f0b$1@smc.vnet.net>
pradeep wrote:
> Hello All,
> is there a way i can selectively clear all but a few variables in
> mathematica?? i have a large number of variables and am iteratively
> running my entire notebook through a loop and want most variables except
> a few to get cleared between iterations..
> any help would be appreciated!
is this what you are after?
In[29]:= {x,y,a,b,c,d}=Range[6]
Out[29]= {1,2,3,4,5,6}
In[30]:= Names["Global`*"]
Out[30]= {a,b,c,d,x,y}
In[31]:= ToExpression/@Names["Global`*"]
Out[31]= {3,4,5,6,1,2}
In[32]:= Clear/@Complement[Names["Global`*"],{"x","y","z"}]
Out[32]= {Null,Null,Null,Null}
In[33]:= ToExpression/@Names["Global`*"]
Out[33]= {a,b,c,d,1,2}
hth,
albert