MathGroup Archive 2008

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

Search the Archive

Re: simple pattern match question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91165] Re: simple pattern match question
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 8 Aug 2008 07:13:33 -0400 (EDT)
  • References: <g7ed78$2po$1@smc.vnet.net>

Just a small error in syntax. What you want is:

f[x_?NumberQ] := x^2

f[3]
9

f[3.3]
10.89


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


<congruentialuminaire at yahoo.com> wrote in message 
news:g7ed78$2po$1 at smc.vnet.net...
> Hello UG:
>
> I am trying to understand simple pattern rule evaulation. The
> following trivial examples baffles me:
>
> ---------------------------------------------------
> In[1]:= f[x_Number] := x ^ 2
> In[2]:= f[3]
> Out[2]= f[3]
>
> In[3]:= f[3.3]
> Out[3]= f[3.3]
>
> In[4]:= NumberQ[3.3]
> Out[4]= True
> --------------------------------------------------
> Why is it that f[3.3] does not evaluate??
>
> TIA.
>
> Regards..RogerW
> 



  • Prev by Date: Re: simple pattern match question
  • Next by Date: Re: Multiplying a vector over multiple vectors
  • Previous by thread: Re: simple pattern match question
  • Next by thread: Re: simple pattern match question