Re: Subscripts, Doh!!!
- To: mathgroup at smc.vnet.net
- Subject: [mg19269] Re: Subscripts, Doh!!!
- From: Colin Rose <colin at tri.org.au>
- Date: Thu, 12 Aug 1999 01:24:24 -0400
- References: <7o5ier$rme@smc.vnet.net> <7oba5o$3p6@smc.vnet.net> <"199908060358.XAA08108"@smc.vnet.net> <v04210100b3d0c0366e0b@[172.16.41.9]>
- Sender: owner-wri-mathgroup at wolfram.com
Jason Harris wrote:
>Just using subscripted symbols has its problems though...
>
>For instance \!\(\(?m\_1\)\), that is ? m sub 1 will yield an
>error. As will something like \!\(Clear[m\_1]\), that is Clear[ m
>sub 1]. etc.
Yes - it would have been nice if Clear[Subscript[m, 1]] had
been 'made to work' in v4. At the moment, one has to use
Unset[Subscript[m, 1]]
or
Clear[Subscript] (which clears all subscripted 'variables').
__
>>
>>(iii) Ideally, one would be able to
>>
>> Symbolize[ Subscript[x, _Integer] ]
>>
>> and then be able to work with
>>
>> Table[x_i, {i, 1, 4}]
>>
>> where each of x_1, x_2, x_3 etc are treated as symbols.
>Here is some code to do what you request. (It looks much better on
>screen than below. It takes only 3 lines on screen.)
>
>Symbolize[
>NotationBoxTag[
> SubscriptBox["m",
> TagBox[RowBox[List["i_", "?", "unparsedNumericQ"]],
> NotationPatternTag,
> Rule[TagStyle, "NotationPatternWrapperStyle"]]]]]
>
>Subscript[m, i_?IntegerQ] := ToExpression @ MakeBoxes @ Subscript[m, i]
>
>unparsedNumericQ @ boxes___ :=
> ReleaseHold @
> Hold[NumericQ] @
> Hold[Unevaluated] @ ToExpression[boxes, StandardForm, Hold]
>
>The function UnparsedNumericQ carefully tries to determine if a
>string is a number without evaluating it.
>
>Here is an illustrative example. (Assuming the Notation package has
>been loaded and the above code entered.)
>
>In[3]:=
>\!\(Table[m\_i, {i, 1, 3}] === {m\_1, m\_2, m\_3}\)
>Out[3]=
>True
Neat. Can you make this work for Greek symbols too,
say mu_1, mu_2 etc, rather than just m_1, m_2, m_3 ?
[ Actually, I had better not advocate such things, or
a lot of my code will cease to work ! heh heh ]
> Of course, this is all possible programmatically so one can
> easily define a function to automate this.
I think it would be valuable if you could add such features to
the next version of Symbolize, in an easily accessible manner.
For instance:
Symbolize[ Subscript[x, _Integer]
switches the above on, for just symbol x,
whilst:
Symbolize[ Subscript[x_, _Integer]
might do it more generally.
Cheers and thanks
Colin
Colin Rose
tr(I) - Theoretical Research Institute
__________________________________________
colin at tri.org.au http://www.tri.org.au/
- Follow-Ups:
- Re: Re: Subscripts, Doh!!!
- From: Carl Woll <carlw@u.washington.edu>
- Re: Re: Subscripts, Doh!!!