MathGroup Archive 2011

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

Search the Archive

Re: Treat subscripted variables as symbols

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120953] Re: Treat subscripted variables as symbols
  • From: Ralph Dratman <ralph.dratman at gmail.com>
  • Date: Thu, 18 Aug 2011 03:24:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j28emt$3fa$1@smc.vnet.net>

I've started using lists of strings instead of symbols in place of what some
programming languages refer to as an "enumerated type." I find it difficult
to keep track of Mathematica's rules of evaluating or not evaluating. I
guess this arises because Mathematica's language does many different kinds
of things with symbols, and tries to be transparent for each type of task.
The result, in terms of references and values and so forth, seems convoluted
to me.

That is not a complaint; I'm having a lot of fun with Mathematica. But when
I want to think like a programmer, I prefer to narrow my view for
utilitarian purposes. That's why I am using strings -- in effect, building
my own symbol tables.

That's wasteful, I'm sure, but so far I can't figure out the right way to do
it. Has anyone constructed a compiler in Mathematica? If so, that code might
tell the tale.

Ralph


On Wed, Aug 17, 2011 at 5:52 AM, Alexey Popkov <lehin.p at gmail.com> wrote:

> You may try to use the SubscriptSymbols command from Andrew Moylan's
> package:
>
> http://sites.google.com/site/andrewjmoylan/mathematica
> http://sites.google.com/site/andrewjmoylan/Moylan.zip
>
> Description from the web-page: "This package makes Mathematica treat all
> the
> subscripts in your notebook as symbols. I used it for a long time because
> it's standard in physics to treat symbols like r, r0, and rcore as unique
> variables.
>
> If you set SubscriptSymbols = True, every expression with head SubscriptBox
> will be transparently converted into a symbol; and that symbol will display
> as the corresponding SubscriptBoxes on output. You won't normally need to
> know about the underlying proxy symbol, but you can use Information[] to
> find out its name."
>
>
> "Camille" <camille.segarra at gmail.com> wrote:
> news:j28emt$3fa$1 at smc.vnet.net...
> > Dear all,
> >
> > I try in mathematica to define a function using subscripted variables and
> > subscripted parameters. It seems however that mathematica is not able to
> > treat these subscripted variables as symbols. Indeed, when I use non
> > subscripted variables and parameters it "works".
> >
> > For example:
> > In: Function[##,Subscript[A, 2] Subscript[x, 1] ] & @@ {Subscript[A, 2]}
> >
> > Out:Function::flpar: Parameter specification Subscript[A, 2] in
> > Subscript[A, 2]\[Function]Subscript[A, 2] Subscript[x, 1] should be a
> > symbol or a list of symbols.
> >
> > But if I do:
> > In: Function[##,A x] & @@ {A}
> > Out: a\[Function]a x
> > (It is "working")
> >
> > Any Idea?
> >
> > Thanks in advance,
> >
> > Camille
> >
> >
> >>>
> >
>
>



  • Prev by Date: why does this call to ListPlot3D crash the kernel?
  • Next by Date: Re: Using Mathematica
  • Previous by thread: Re: Treat subscripted variables as symbols
  • Next by thread: Unprotect