Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

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


  • Prev by Date: Repost - help with list manipulation
  • Next by Date: Re: Frontend suggestions
  • Previous by thread: Re: Repost - help with list manipulation
  • Next by thread: Re: Problem with using Symbol[] in a loop