Re: Clear subscripted variables
- To: mathgroup at smc.vnet.net
- Subject: [mg58319] Re: Clear subscripted variables
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Tue, 28 Jun 2005 05:13:19 -0400 (EDT)
- Organization: Uni Leipzig
- References: <d9ispk$cpd$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
ClearSubscript[x_Symbol] := (First /@
Select[DownValues[Subscript],
MatchQ[First[#],
Verbatim[HoldPattern][Subscript[x, _]]] &]) /.
HoldPattern :> Unset
and
ClearSubscript[x] will remove all Subscript[x,_]
values.
Regards
Jens
"Mukhtar Bekkali" <mbekkali at gmail.com> schrieb im
Newsbeitrag news:d9ispk$cpd$1 at smc.vnet.net...
> Here is the code (x\_i stands for x subscript
> i):
>
> Table[{Print[x\_i = i]; Clear[x]; Remove[x];
> Unset[x]; Print[x\_i]},
> {i, 1, 2}]
>
> I expected that x\_i is cleared at the end of
> the loop but it isn't
>
> If I insert Clear[Subscript] in the loop then it
> is cleared, but not
> desirable since it clears all variables with
> subscripts.
>
> What command shall I use to clear specific
> subscripted variables?
>
> Mukhtar Bekkali
>