Re: Help with Hold
- To: mathgroup at smc.vnet.net
- Subject: [mg100933] Re: [mg100917] Help with Hold
- From: John Fultz <jfultz at wolfram.com>
- Date: Thu, 18 Jun 2009 06:18:27 -0400 (EDT)
- Reply-to: jfultz at wolfram.com
On Thu, 18 Jun 2009 04:52:55 -0400 (EDT), Erich Neuwirth wrote:
> How can I transform
>
> Hold[x,Null,y,Null,Null]
> into
> {"x",Null,"y",Null,Null}
> even if x and/or y have assigned values?
Not sure if this is the most concise/clever way, but it certainly works. I
assume here that your criteria for choosing 'x' and 'y', but not 'Null' is that
'x' and 'y' are symbols and in the Global` context.
isGlobalSymbol[x_Symbol] := Context[x] === "Global`";
isGlobalSymbol[x_] := False;
SetAttributes[isGlobalSymbol, HoldAll];
List @@ (Hold[x, Null, y, Null, Null] /.
var_?isGlobalSymbol :> ToString[Unevaluated[var]])
Sincerely,
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.
- Follow-Ups:
- Re: Re: Help with Hold
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Re: Help with Hold