Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4472

Re: Treat subscripted variables as symbols

From "Alexey Popkov" <lehin.p@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Treat subscripted variables as symbols
Date 2011-08-19 10:33 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j2le56$nca$1@smc.vnet.net> (permalink)
References <j28emt$3fa$1@smc.vnet.net><201108170952.FAA01404@smc.vnet.net> <CAO-JnY2jSHRtjFY6OGNXrwACnUW4P+9vFZO-Q_2hCV02K19B9A@mail.gmail.com>

Show all headers | View raw


----- Original Message ----- 
From: "Ralph Dratman" <ralph.dratman@gmail.com>
To: "Alexey Popkov" <lehin.p@gmail.com>
Cc: <mathgroup@smc.vnet.net>
Sent: Wednesday, August 17, 2011 7:37 PM
Subject: 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 

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Treat subscripted variables as symbols Camille <camille.segarra@gmail.com> - 2011-08-14 12:22 +0000
  Re: Treat subscripted variables as symbols Simon <simonjtyler@gmail.com> - 2011-08-15 00:23 +0000
  Re: Treat subscripted variables as symbols "Alexey Popkov" <lehin.p@gmail.com> - 2011-08-17 09:53 +0000
  Re: Treat subscripted variables as symbols Ralph Dratman <ralph.dratman@gmail.com> - 2011-08-18 07:29 +0000
  Re: Treat subscripted variables as symbols "Alexey Popkov" <lehin.p@gmail.com> - 2011-08-19 10:33 +0000

csiph-web