Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Re: Help with Hold

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100963] Re: [mg100933] Re: [mg100917] Help with Hold
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Thu, 18 Jun 2009 20:48:05 -0400 (EDT)
  • References: <200906181018.GAA24553@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

Or:

variable[Null] = False;
variable[x_Symbol] = True;
variable[x_] = False;
SetAttributes[variable, HoldAll];
x = 1
List @@ (Hold[x, Null, y, Null, Null] /.
    var_?variable :> ToString[Unevaluated[var]])

1

{"x", Null, "y", Null, Null}

On Thu, 18 Jun 2009 05:18:27 -0500, John Fultz <jfultz at wolfram.com> wrote:

> 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.
>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: Plotting surface with thickness
  • Next by Date: Re: Strange Solve result after previous bad input
  • Previous by thread: Re: Help with Hold
  • Next by thread: Re: Help with Hold