MathGroup Archive 2011

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

Search the Archive

Re: HoldAll/HoldRest

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118500] Re: HoldAll/HoldRest
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sat, 30 Apr 2011 05:51:01 -0400 (EDT)

No evaluation takes place in the expression 5, so:

x = 5;
ValueQ[x]
ValueQ[5]

True

False

We could also do this:

ClearAll[valueQ, x]
valueQ[x_?NumericQ] = True;
valueQ[x_] := If[ValueQ@x, x, False, False]
x = 5;
valueQ@x
valueQ@5

True

True

But I can't tell whether that's really what you want, or not.

Bobby

On Fri, 29 Apr 2011 06:33:59 -0500, Scot T. Martin  
<smartin at seas.harvard.edu> wrote:

> Some kind of issue going on here between the interactions of HoldAll of  
> ValueQ[...] and HoldRest of If[...]. Anyone know the solution so that  
> Out[3] results in True?
> =
> =
> In[1]:= valueQ = If[ValueQ[#], #, False] &
> =
>
> =
> Out[1]= If[ValueQ[#1], #1, False] &
> =
>
> =
> In[2]:= x = 5
> =
>
> =
> Out[2]= 5
> =
>
> =
> In[3]:= valueQ[5]
> =
>
> =
> Out[3]= False


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Report PDF's
  • Next by Date: Re: Solve / Reduce isolating results.
  • Previous by thread: Re: HoldAll/HoldRest
  • Next by thread: Report PDF's