Mathematica 9 is now available

WhichCompoundExpression (;)

Switch

FilledSmallSquareSwitch[expr, , , , , ... ] evaluates expr, then compares it with each of the in turn, evaluating and returning the corresponding to the first match found.

FilledSmallSquare Only the corresponding to the first that matches expr is evaluated. Each is evaluated only when the match is tried.

FilledSmallSquare If the last is the pattern _, then the corresponding is always returned if this case is reached.

FilledSmallSquare If none of the match expr, the Switch is returned unevaluated.

FilledSmallSquareSwitch has attribute HoldRest.

FilledSmallSquare You can use Break, Return and Throw in Switch.

FilledSmallSquare See The Mathematica Book: Section 2.5.8.

FilledSmallSquare See also: If, Condition, Which.

Further Examples

WhichCompoundExpression (;)



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