MathGroup Archive 2002

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

Search the Archive

Re: Conditional evaluation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34308] Re: Conditional evaluation
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 14 May 2002 04:11:44 -0400 (EDT)
  • References: <abo3d7$5dm$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Tim,

myFunc[x_] := 2 /; x == 1
myFunc[x_] := 3

The second line serves the default.
--

Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Tim Ebringer" <drearyslig at hotmail.com> wrote in message
news:abo3d7$5dm$1 at smc.vnet.net...
> 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: Factor Polynomials
  • Next by Date: Re: Conditional evaluation
  • Previous by thread: RE: Conditional evaluation
  • Next by thread: Re: Conditional evaluation