Problem with using Symbol[] in a loop
- To: mathgroup at smc.vnet.net
- Subject: [mg111793] Problem with using Symbol[] in a loop
- From: Bob F <deepyogurt at gmail.com>
- Date: Fri, 13 Aug 2010 06:57:17 -0400 (EDT)
Can anyone tell me why this works as expected:
dirnames = Names["$*Directory*"];
For[i = 0, i < Length[dirnames], i++; Print[dirnames[[i]]]]
and gives the following results:
$AddOnsDirectory
$BaseDirectory
$HomeDirectory
$InitialDirectory
$InstallationDirectory
$LaunchDirectory
$PreferencesDirectory
$RootDirectory
$TemporaryDirectory
$TopDirectory
$UserAddOnsDirectory
$UserBaseDirectory
$UserBasePacletsDirectory
$UserDocumentsDirectory
But that the following doesn't give any results:
dirnames = Names["$*Directory*"];
For[i = 0, i < Length[dirnames], i++; Symbol[dirnames[[i]]]]
but if I go thru the dirnames array elements manually it works as I
would expect, e.g.
In[161]:= Symbol[dirnames[[1]]]
Out[161]= "/Library/Mathematica"
Why does the Print[dirnames[[i]]] work OK but the
Symbol[dirnames[[i]]] fail to give anything?
Thanks...
-Bob