Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #1919 > unrolled thread

Re: HoldAll/HoldRest

Started byDrMajorBob <btreat1@austin.rr.com>
First post2011-04-30 09:51 +0000
Last post2011-04-30 09:51 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: HoldAll/HoldRest DrMajorBob <btreat1@austin.rr.com> - 2011-04-30 09:51 +0000

#1919 — Re: HoldAll/HoldRest

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-04-30 09:51 +0000
SubjectRe: HoldAll/HoldRest
Message-ID<ipgm2i$8oh$1@smc.vnet.net>
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@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@yahoo.com

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web