MathGroup Archive 2009

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

Search the Archive

Problems with Evaluate[Symbol[xxx]]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102759] Problems with Evaluate[Symbol[xxx]]
  • From: Keelin <keelinm at gmail.com>
  • Date: Wed, 26 Aug 2009 07:44:06 -0400 (EDT)

Hi,
I'm trying to use the Evaluate[Symbol[xxx]] syntax but I think I am
misunderstanding something as it is not behaving as I expect.  Below
is an example to illustrate what is unexpected:
The questions are:
1) Is there a problem with line 604 - it gives errors, but yet the
output in the end is correct
2) Why are the output of abc and the output of Evaluate[Symbol
[myListIdentifier]] not regarded as equal even though they appear
identical (See line 608)
3) Why can I append correctly using the reference name abc, but not
using the Evaluate[Symbol[myListIdentifier]] name?  This is what I
really want to do in the end - append to a list which has a
dynamically assigned variable name.

Thanks!!


In[602]:= (*Make an identifier string to hold some data*)
myListIdentifier = "abc"

Out[602]= "abc"

In[603]:= (*here's the data*)
myList = {{7, 8}}

Out[603]= {{7, 8}}

In[604]:= (*Now put the data into a variable with name abc*)
Evaluate[Symbol[myListIdentifier]] = myList

During evaluation of In[604]:= Set::setraw: Cannot assign to raw \
object 7. >>

During evaluation of In[604]:= Set::setraw: Cannot assign to raw \
object 8. >>

Out[604]= {{7, 8}}

In[605]:=
(*Check abc holds the correct data*)
abc

Out[605]= {{7, 8}}

In[606]:= (*Check the data can also be accessed using the \
myListIdentifier*)

In[607]:= Evaluate[Symbol[myListIdentifier]]

Out[607]= {{7, 8}}

In[608]:= (*But apparently the two items are not equal... why??*)
abc == Evaluate[Symbol[listIdentifier]]

Out[608]= False

In[609]:= (*Even worse, I can append using the reference abc, but not
\
using the myListIdentifier*)
Append[abc, {3}]

Out[609]= {{7, 8}, {3}}

In[610]:= Append[Evaluate[Symbol[listIdentifier]], {3}]

Out[610]= {{3}}


  • Prev by Date: Re: Newcomer Question
  • Next by Date: DynamicModule causing problems with Manipulate setter bar
  • Previous by thread: using interpolating function as initial condition to Ndsolve
  • Next by thread: Re: Problems with Evaluate[Symbol[xxx]]