MathGroup Archive 2008

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

Search the Archive

Re: Parameter conditions


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