MathGroup Archive 2008

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

Search the Archive

Re: Parameter conditions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88667] Re: Parameter conditions
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Mon, 12 May 2008 04:45:28 -0400 (EDT)
  • References: <g07gt8$8ro$1@smc.vnet.net>

Steven Siew wrote:
> I'm just curious why the simple code below is not working.
> 
> Why is happy[4] not returning the number 200
> 
> 
> In[1]:=  happy[p_?PrimeQ] = 100;
>            happy[p_?Not[PrimeQ]] = 200;
> 
> In[3]:=  Inhappy[4]
> Out[3]:= happy[4]
> 
> In[4]:=  happy[5]
> Out[4]:=  100
> 
The pattern p_?Not[PrimeQ] is wrong - try using

p_/;Not[PrintQ[p]]

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Intersection of surfaces
  • Next by Date: Flashing Graphs With Manipulate
  • Previous by thread: Re: Parameter conditions
  • Next by thread: Re: Parameter conditions