MathGroup Archive 2008

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

Search the Archive

Re: Clearing selected variables

  • To: mathgroup at
  • Subject: [mg86644] Re: Clearing selected variables
  • From: Albert Retey <awnl at>
  • Date: Sat, 15 Mar 2008 17:45:38 -0500 (EST)
  • References: <frg0ef$f0b$>

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}



  • Prev by Date: Re: Pi is not a real number?
  • Next by Date: Re: ScatterPlot3D
  • Previous by thread: Bug: Derivative[] does not work with functions having slots in their
  • Next by thread: Re: Clearing selected variables