MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: subscripted local variables?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80749] Re: subscripted local variables?
  • From: Andrew Moylan <andrew.j.moylan at gmail.com>
  • Date: Thu, 30 Aug 2007 23:47:49 -0400 (EDT)
  • References: <fath6p$3o7$1@smc.vnet.net><fb5opp$959$1@smc.twtelecom.net>

Kevin's method using the Notation package is one of the "various ways
to get around this" that I was referring to. That way is especially
good if you want to make some, but not all, subscripts (or other
objects) behave as symbols. Unfortunately, it suffers from the same
Mathematica 6 change regarding auto-generated package files as my
SubscriptSymbols package.

On Aug 30, 4:40 pm, "Kevin J. McCann" <Kevin.McC... at umbc.edu> wrote:
> I disagree with the previous comments on the use of subscripted symbols.
> I do it all the time. Here is what I suggest:
>
> Use the Notation package. Here is an example. You should note that in
> this example "xsub2" is turned into a symbol. This means that Mathematica puts a
> wrapper around it so that it treats "xsub2" as a symbol. Drop the stuff
> below into a new notebook, highlight the whole thing and do a
> Cntrl-Shift-N to see the notation, then execute.
>
> Kevin
>
> (*Here is a simple subscript, which works ok unless x is defined:*)
>
> Subscript[x, 2]
>
> FullForm[Subscript[x, 2]]
>
> x = 3;
>
> Subscript[x, 2]
>
> (*Ooops! Now undefine x:*)
>
> x =.
>
> (*and load the Notation package*)
>
> << Notation`
>
> (*Use the Symbolize button from the Notation Palette:*)
>
> Symbolize[\!\(\*
> TagBox[
> SubscriptBox["x", "2"],
> "NotationTemplateTag"]\)]
>
> (*Now, note that the FullForm has changed:*)
>
> FullForm[Subscript[x, 2]]
>
> (*Mathematica has put a sort of wrapper around the whole thing so \
> that it is treated as a single entity. Now let's define x again:*)
>
> x = 3;
>
> (*This time, however, everything works:*)
>
> Subscript[x, 2]




  • Prev by Date: Re: Re: fit a BinomialDistribution to exptl data?
  • Next by Date: Animation of a rotating object. (Mathematica 6)
  • Previous by thread: Re: subscripted local variables?
  • Next by thread: Problem with With