Re: Conditional evaluation
- To: mathgroup at smc.vnet.net
- Subject: [mg34287] Re: [mg34281] Conditional evaluation
- From: BobHanlon at aol.com
- Date: Tue, 14 May 2002 04:09:55 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 5/13/02 6:40:26 AM, drearyslig at hotmail.com writes: >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. > myFunc[x_]:=a/;Head[x]==Complex; myFunc[x_]:=b; myFunc /@ {3+4I, 3, 3., 4I, c, 3/4} {a, b, b, a, b, b} Bob Hanlon Chantilly, VA USA