Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2008

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

Search the Archive

Re: Conditional SetDelayed with Replacement

  • To: mathgroup at
  • Subject: [mg92859] Re: Conditional SetDelayed with Replacement
  • From: yatesd at
  • Date: Wed, 15 Oct 2008 05:38:37 -0400 (EDT)
  • References: <gcv7d5$e1i$>

Others have shown how to create what you want using With (and that
technique is very important), but the type of function you are
creating here is also a good candidate for Piecewise:

f[x_] := Evaluate[Piecewise[Transpose[{Thread[x < Range[5]^2],

where I have put in the Evaluate so that the Piecewise function does
not have to be created each time f is called.

Information[f] shows you that the definition stored for f is now

You could also use Table instead of the Thread and Transpose used


gives the same result, and is probably easier to read.



  • Prev by Date: Partial Differential Equations
  • Next by Date: Re: Easiest Mathematica algorhitm needed
  • Previous by thread: Re: Conditional SetDelayed with Replacement
  • Next by thread: Re: Getting rid of those deprecated Doloops?