MathGroup Archive 2008

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

Search the Archive

Re: Clearing selected variables

  • To: mathgroup at
  • Subject: [mg86648] Re: Clearing selected variables
  • From: David Bailey <dave at>
  • Date: Sun, 16 Mar 2008 04:38:41 -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!
> thanks!
> Pradeep
> Purdue University
By far the best technique is to wrap your calculations in Module or 
Block and use local variables. Each time the Module or Block construct 
terminates the local variables are lost - so your big loop should go 
outside these constructs. Those variables that you want to keep, should 
not be local, so as Global variables they will carry over from one 
iteration to the next.

David Bailey

  • Prev by Date: Re: Clearing selected variables
  • Next by Date: Re: Re: Pi is not a real number?
  • Previous by thread: Re: Clearing selected variables
  • Next by thread: Re: Clearing selected variables