Re: Interaction of Remove and Global variables in a Module
- To: mathgroup at smc.vnet.net
- Subject: [mg120210] Re: Interaction of Remove and Global variables in a Module
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 13 Jul 2011 03:11:23 -0400 (EDT)
On 7/12/11 at 6:59 AM, gianluca.gorni at uniud.it (Gianluca Gorni) wrote: >Suppose now that I do it more traditional-looking: >Subscript[a, 0] = 1; Subscript[a, n_] := >Subscript[a, n] = 2 Subscript[a, n - 1]; >If I call Subscript[a, 2], its value will be remembered. What can I >do to clear the values? Clear[a] and ClearAll[a] do not work. >Remove[a] does work. >Is there a better alternative? If you want to use subscripted variables in the same manner as normal variables (symbols) in Mathematica, then load the Notation package and use Symbolize. Then they will behave as symbols. If you choose not to use the Notation package you will run into difficulties at times because something with Head Subsecript simply isn't a Symbol and will not behave in all respects like a Symbol. For me, the effort to created subscripted variables that behave like normal variables in Mathematica is much more effort than it is worth. The only reason I ever use subscripted variables in Mathematica is when I want the output to look like traditional type set math you might find in a text and my intended audience is colleagues which do not have Mathematica or are otherwise unfamiliar with Mathematica. In these cases, what I will be sending my colleagues is a static PDF file. So, I can evaluate things using unsubscripted variables and edit them later so they appear as having been done with subscripted variables. And if I was sending something to a colleague who had Mathematica and was familiar with it, I would send him the Mathematica notebook and would not use subscripted variables.