MathGroup Archive 2008

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

Search the Archive

Re: Clearing selected variables


On Mar 15, 9:13=A0am, pradeep <prad... at purdue.edu> 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

Why don't you localize those variables that need to be cleared with a
Module or a Block?  Explicitly Clear[]ing symbols in a loop sounds
like something that could lead to trouble and confusion ...

Here's a way to clear all names in the Global context except a, b, and
c:

Clear @@ Complement[Names["Global`*"], {"a", "b", "c"}]


  • Prev by Date: Re: Substitute all known relations in result
  • Next by Date: Re: Substitute all known relations in result
  • Previous by thread: Re: Clearing selected variables
  • Next by thread: Re: Clearing selected variables