MathGroup Archive 2008

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

Search the Archive

Re: Clearing selected variables

  • To: mathgroup at
  • Subject: [mg86630] Re: [mg86625] Clearing selected variables
  • From: Bob Hanlon <hanlonr at>
  • Date: Sat, 15 Mar 2008 17:42:59 -0500 (EST)
  • Reply-to: hanlonr at

Create variables and make assignments

ToExpression[Table["x" <> ToString[n] <> " = 1", {n, 20}]];

exclusions = {"x5", "x9", "exclusions"};

Verifying that assignments have been made



Clear all assignments except variables in exclusions

ToExpression[# <> "=." & /@ Complement[Names["Global`*"], exclusions]];

Verifying that appropriate assignments have been cleared



Remove all variables except those in exclusions

  "Remove[" <> # <> "]" & /@ Complement[Names["Global`*"], exclusions]];

verifying that appropriate variables have been removed



Bob Hanlon

---- pradeep <pradeep at> 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

  • Prev by Date: Re: Substitute all known relations in result
  • Next by Date: Re: ordering of multivariate polynomial terms
  • Previous by thread: Re: Clearing selected variables
  • Next by thread: Re: Clearing selected variables