MathGroup Archive 2007

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

Search the Archive

Re: Evaluation question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82208] Re: Evaluation question
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Mon, 15 Oct 2007 01:19:26 -0400 (EDT)
  • References: <200710120656.CAA04613@smc.vnet.net> <fepuqv$hvl$1@smc.vnet.net> <47109042.2000302@gmail.com> <AF26334E-9827-4055-8FEF-501F79F783AE@mimuw.edu.pl> <fesr61$pjb$1@smc.vnet.net>

Andrzej Kozlowski wrote:
> On 14 Oct 2007, at 08:00, Andrzej Kozlowski wrote:
> 
> 
>> Wihtout evaluation 1+2 is just a symbol and not the number 3 so 
>> NumericQ returns False.
> 
> I should have been more precise. Unevaluated 1+2 is an expression 
> (rather than a symbol); in fact it is the expression Plus[1,2], which 
> of course is not numeric. It's value is, of course, numeric, but that 
> is obtained only after evaluation.

But Plus has the attribute NumericFunction, therefore it should be 
considered "numerical" whenever all of its arguments are numerical.

For example, see In[2] and In[3] below.  f[1,2] stays unevaluated, but 
NumericQ[f[1,2]] still returns True because 'f' has the attribute 
NumericFunction, and all of its arguments (1 and 2) are numerical.

>>> In[1]:= NumericQ[Unevaluated[1+2]]//Trace
>>> Out[1]= {NumericQ[1+2],False}
>>>
>>> In[2]:= SetAttributes[f,NumericFunction]
>>>
>>> In[3]:= NumericQ[f[1,2]]//Trace
>>> Out[3]= {NumericQ[f[1,2]],True}
>>>
>>> In[4]:= NumericQ[Unevaluated[f[1,2]]]//Trace
>>> Out[4]= {NumericQ[f[1,2]],False}
>>>
>>
>> I do not find this surprising. Wihtout evaluation 1+2 is just a 
>> symbol and not the number 3 so NumericQ returns False.
>>

-- 
Szabolcs


  • Prev by Date: ProgressIndicator Questions
  • Next by Date: Re: Manipulator Import in Powerpoint
  • Previous by thread: Re: Evaluation question
  • Next by thread: Re: Evaluation question