Mathematica 9 is now available

Which

Which[ ,  ,  ,  , ... ] evaluates each of the  in turn, returning the value of the  corresponding to the first one that yields True.

• Example: Which[1 Equal 2, x, 1 Equal 1, y] LongRightArrow  .
• If any of the  evaluated by Which give neither True nor False, then a Which object containing these remaining elements is returned unevaluated.
• You can make Which return a "default value" by taking the last  to be True.
• If all the  evaluate to False, Which returns Null.
• See also:
If.

Examples

Using InstantCalculators

Here is the InstantCalculator for the Which function. Enter the parameters for your calculation and click Calculate to see the result.

Entering Commands Directly

You can paste a template for this command via the Text Input button on the Which Function Controller.

Here is a simple example using Which.

Here is a plot of a piecewise-defined function.



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.