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


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

Re: HoldAll/HoldRest

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: HoldAll/HoldRest
Date 2011-04-30 09:51 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ipgm2i$8oh$1@smc.vnet.net> (permalink)

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web