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


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

Re: HoldAll/HoldRest

From Albert Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: HoldAll/HoldRest
Date 2011-04-30 09:53 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ipgm60$8re$1@smc.vnet.net> (permalink)
References <ipe7mu$r23$1@smc.vnet.net>

Show all headers | View raw


Hi,

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

It's Function which evaluates its arguments by default, you can do:

valueQ = Function[Null, If[ValueQ[#], #, False], HoldAll]

to avoid that.

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

I guess that should be valueQ[x], otherwise you shouldn't wonder about 
the result...

hth,

albert

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


Thread

Re: HoldAll/HoldRest Albert Retey <awnl@gmx-topmail.de> - 2011-04-30 09:53 +0000

csiph-web