Re: Simple question about named variables.
- To: mathgroup at smc.vnet.net
- Subject: [mg101239] Re: Simple question about named variables.
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 27 Jun 2009 06:06:15 -0400 (EDT)
- References: <firstname.lastname@example.org>
Hi, the best is to avoid Test1, Test2 and use test and test instead but ClearI[i_] := Clear @@ ToExpression[StringJoin["Test", ToString[i]], InputForm, Hold] will work too. Regards Jens Pianiel wrote: > Dear Mathematica users, > > I would like to write a function which clears many variables called: > > Test1,Test2,... > > So I write the function: > > ClearI[i_] := Clear@ToExpression@StringJoin["Test", ToString@i] > > Test1 = 1; > Test2 = 2; > > > ClearI does not work because the expression is evaluated. What > mathematica does is Clear@1. How could I ask Mathematica to do > Clear@Test1, Clear@Test2, ... automatically? > > I am sure that the solution is simple... but I could not find it. > > Thank you in advance > > Pianiel >