Switch
Usage
• Switch[expr, , , , , ... ] 计算 expr, 然后轮流和每个  比较,计算并返回相应于找到的第一个匹配的  .
Notes
• 只有相应于第一个与 expr匹配的  的  被计算.仅当进行匹配尝试时,每个  被计算. • 如果最后一个  是 pattern _, 则如果达到这种情况,相应的  总是不计算返回. • 如果没有一个  匹配 expr, Switch不计算返回. • Switch 有属性 HoldRest. • 可以在 Switch中使用Break, Return和Throw. • 参见 Mathematica 全书 : 节 2.5.8.
Further Examples
The output of this function depends on the type of the input.
In[1]:=
|
In[2]:=
|
Out[2]=
|
In[3]:=
|
|