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: [mg120955] Re: Treat subscripted variables as symbols
  • From: "Alexey Popkov" <lehin.p at gmail.com>
  • Date: Fri, 19 Aug 2011 06:32:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j28emt$3fa$1@smc.vnet.net><201108170952.FAA01404@smc.vnet.net> <CAO-JnY2jSHRtjFY6OGNXrwACnUW4P+9vFZO-Q_2hCV02K19B9A@mail.gmail.com>

----- Original Message ----- 
From: "Ralph Dratman" <ralph.dratman at gmail.com>
To: "Alexey Popkov" <lehin.p at gmail.com>
Cc: <mathgroup at smc.vnet.net>
Sent: Wednesday, August 17, 2011 7:37 PM
Subject: [mg120955] Re: Treat subscripted variables as symbols


> 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

You can convert a string containing correct symbol name to a symbol by using 
the Symbol command or by using ToExpression. Note three-argument form of 
ToExpression:
ToExpression["symbolName",InputForm,yourFunction]
This form allows you to pass your symbol to arbitrary function with Hold* 
attribute without evaluating your symbol.

You can find description of the standard evaluation sequence on the top of 
the following Documentation page:
http://reference.wolfram.com/mathematica/tutorial/Evaluation.html
I strongly reccommend to become familiar with the standard evaluation 
sequence bacause it explains many "strange" aspects of expression evaluation 
in Mathematica. Some experiments with the Trace command my help with 
understanding it significantly. You could also try to use WReach's traceView 
utilities:
http://stackoverflow.com/questions/5459735/the-clearest-way-to-represent-mathematicas-evaluation-sequence 





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