MathGroup Archive 2002

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

Search the Archive

RE: Conditional evaluation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34294] RE: [mg34281] Conditional evaluation
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Tue, 14 May 2002 04:10:04 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

How's this?

ClearAll[expr,myFunc,a,b,c]
expr[x_]:=x>1;
myFunc[x_]:=a /; expr[x]
myFunc[x_]:=b /; !(expr[x])
myFunc[x_]:=c
myFunc/@{0,1,2,"a"}

{b,b,a,c}

Bobby

-----Original Message-----
From: Tim Ebringer [mailto:drearyslig at hotmail.com] 
To: mathgroup at smc.vnet.net
Subject: [mg34294] [mg34281] Conditional evaluation

Greetings gurus,

Does anyone know how to do the expression If[expr, a, b, b] using the
conditional /; operation, i.e.

myFunc[x_]:=a /; expr
myFunc[x_]:=b /; <otherwise>

I could do it using the If function, but would much prefer, for layout
reasons, to use the conditional operator, but I can't seem to make it do
the
"otherwise" part. Note that !expr doesn't work in this case because it
doesn't evaluate.

Cheers,

Tim.







  • Prev by Date: Re: TeX Problems
  • Next by Date: RE: Factor Polynomials
  • Previous by thread: Re: Conditional evaluation
  • Next by thread: Re: Conditional evaluation