If• If[condition, t, f] gives t if condition evaluates to True, and f if it evaluates to False. • If[condition, t, f, u] gives u if condition evaluates to neither True nor False. • If evaluates only the argument determined by the value of the condition. • If[condition, t, f] is left unevaluated if condition evaluates to neither True nor False. • If[condition, t] gives Null if condition evaluates to False. • See also: Which, While.
Examples Using InstantCalculatorsHere are the InstantCalculators for the If function. Enter the parameters for your calculation and click Calculate to see the result.
Entering Commands DirectlyYou can paste a template for this command via the Text Input button on the If Function Controller. The test gives False, so y is returned.
Out[4]= |  |
The test gives neither True nor False, so neither branch is evaluated.
Out[5]= |  |
If there is a fourth argument to If, it is used when the test does not yield True or False.
Out[6]= |  |
|