Legacy Documentation

Mathematica CalcCenter 2 (2002)

This is documentation for an obsolete product.
Current products and services

Documentation / CalculationCenter / Functions / Defining Functions / Conditionals /

Which

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

FilledSmallSquare Example: Which[1 == 2, x, 1 == 1, y] LongRightArrow .

FilledSmallSquare If any of the evaluated by Which give neither True nor False, then a Which object containing these remaining elements is returned unevaluated.

FilledSmallSquare You can make Which return a "default value" by taking the last to be True.

FilledSmallSquare If all the evaluate to False, Which returns Null.

FilledSmallSquare 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.

In[1]:=

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.

In[2]:=

Out[2]=

Here is a plot of a piecewise-defined function.

In[3]:=



ja