Mathematica 9 is now available

If

Usage

• 如果计算conditionTrueIf[condition, t, f]给出 t ,如果为False,则给出 f
• 如果计算condition既不是True也不是False,则If[condition, t, f ,u]给出 u


Notes

If 仅计算由条件值决定的自变量。
• 如果计算condition既不是True也不是FalseIf[condition, t, f]不进行计算。
• 如果计算conditionFalseIf[condition, t] 给出Null
• 参见 Mathematica 全书: 1.5.6 and 节 2.5.8.
• 同时参见: Switch, Which, Condition, DiracDelta.
Further Examples

The test gives False, so y is returned.

In[1]:=  

Out[1]=

The test gives neither True nor False, so neither branch is evaluated.

In[2]:=  

Out[2]=

If there is a fourth argument to If, it is used when the test does not yield True or False.

In[3]:=  

Out[3]=



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.