Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Symbol name extraction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73791] Re: Symbol name extraction
  • From: albert <awnl at arcor.de>
  • Date: Wed, 28 Feb 2007 04:39:52 -0500 (EST)
  • References: <errlbu$83p$1@smc.vnet.net><erug0d$sm6$1@smc.vnet.net> <es11sh$n54$1@smc.vnet.net>

Hi,

> I was quite aware of the method using HoldAll attributes, but I wanted
> only 1 function, and not two or three that subsequently call each
> other. For this reason, I'm using Albert's solution that seems to be
> pretty simple and compact, aside for the branching.

You can avoid the branching by using a pure function like this:

SetAttributes[printSymbol,HoldAll];

printSymbol[vars_List]:=StringJoin[Map[
  Function[
    {var},
    SymbolName[Unevaluated[var]]<>"="<>ToString[var,InputForm]<>";\n",
    HoldAll
  ],
  Unevaluated[vars]
]];

> Is there a more clearcut way?

note that the construction with Unevaluated[vars] which I copied from David
Bailey's version is shorter and probably more clearcut than my original
ReleaseHold + Hold construct. Still I wouldn't consider the whole function
as "clearcut" :-)

hth,

albert


  • Prev by Date: Re: multi-threading on Mac OS X.
  • Next by Date: Re: Problems...
  • Previous by thread: Re: Symbol name extraction
  • Next by thread: Re: Symbol name extraction