MathGroup Archive 2007

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

Search the Archive

Re: Symbol name extraction


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