Re: Clear variables in a list
- To: mathgroup at smc.vnet.net
- Subject: [mg112072] Re: Clear variables in a list
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 29 Aug 2010 02:49:13 -0400 (EDT)
In your example, once vars is evaluated it is a list of values with no memory of from where the values came.
a = 1; b = 2; c = 3; vars = Hold[{a, b, c}];
vars // Release
{1,2,3}
To Clear, use
vars /. List :> Clear // Release
vars // Release
{a,b,c}
Bob Hanlon
---- Chris Degnen <degnen at cwgsy.net> wrote:
=============
Any suggestions how to clear variables in a list, eg:
a = 1; b = 2; c = 3; vars = {a, b, c};
None of these work:
Map[Clear, vars]
Map[Clear[Unevaluated[#]] &, vars]
Apply[Clear, vars, {1}]
Only this works: Clear[a, b, c]