Re: Evaluating Global Variables Named Strings as
- To: mathgroup at smc.vnet.net
- Subject: [mg105494] Re: [mg105465] Evaluating Global Variables Named Strings as
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 5 Dec 2009 05:33:05 -0500 (EST)
- Reply-to: hanlonr at cox.net
I forgot to check the previous response with both list and atomic results. Column[ Flatten[{#, Column[ Flatten[{ToExpression[#]}, 1]]} & /@ {"$AddOnsDirectory", "$BaseDirectory", "$Path", "$ProductInformation"}, 1], Spacings -> 1.5] Bob Hanlon ---- Bob Hanlon <hanlonr at cox.net> wrote: ============= Column[Flatten[{#, Column[ToExpression[#]]} & /@ {"$Path", "$ProductInformation"}, 1], Spacings -> 1.5] Bob Hanlon ---- Benjamin Tubb <brtubb at embarqmail.com> wrote: ============= Great! The use of the ToExpression function was exactly what I was looking for (and have since discovered, besides many other things, from reading David B. Wagner's book "Power Programming with Mathematica The Kernel" from which its computer scientist's perspective, is one which I have the most affinity for, as my own background is as a (retired) Navy Data Processing Technician. Regrettably, Wagner never apparently (and regrettably!) wrote, for some reason (?), the "sequel" books to it mentioned. Except for Roman Maeder's two programming books, I've found Wagner's book among the most insightful programming books which I've ever read! However, most of my "crop" of Mathematica books are from the version 3 period, not since having the "debt budget" to indulge in such expenses anymore. I found your second "solution" preferable using Column and Flatten, but adapting it to what I wanted for the "complex" original list produced some curious results: Column[ Flatten[ a = {#, ToExpression[#]} & /@ Names["System`$*"]], Spacings -> 1.5] However, there was one side effect which I didn't want: the complete flattening of the results, which resulted in multple columns of lines (which I preferred as being word-wrapped within one cell), but I can hopefully figure out how to prevent that on my own. Your help has been very appreciated! --- Benjamin Tubb Bob Hanlon wrote: > Grid[ > a = {#, ToExpression[#]} & /@ > {"$AddOnsDirectory", > "$BaseDirectory"}, > Spacings -> {1.5, 1.5}] > > Column[Flatten[ > a = {#, ToExpression[#]} & /@ > {"$AddOnsDirectory", > "$BaseDirectory"}], > Spacings -> 1.5] > > > Bob Hanlon > > ---- BenT <brtubb at pdmusic.org> wrote: > > ============= > Consider the output of this: > > a=Names["System`$*"] > > How does one then process/evaluate each String element of the > resulting List, as the global function name which it represents? > > For a more direct (simpler) example: if given > > a={$AddOnsDirectory,$BaseDirectory} > > Then this output is obtained. > > {C:\Documents and Settings\All Users\Application Data\Mathematica,C: > \Documents and Settings\All Users\Application Data\Mathematica} > > However what I really want to be able to do is process "a" somehow so > that I get the effect of multiple Input cells with their corresponding > Output cells displayed, namely: > > $AddOneDirectory > > C:\Documents and Settings\All Users\Application Data\Mathematica > > $BaseDirectory > > C:\Documents and Settings\All Users\Application Data\Mathematica > > How is this achieved? > > --- Benjamin Tubb