Mathematica 9 is now available

Catch

Usage

Catch[expr] 返回在计算expr时产生的第一个Throw的参数。
Catch[expr, form]返回form匹配tag的第一个 Throw[value, tag]值。
Catch[expr, form, f] 返回f[value, tag].


Notes

如果在计算时不产生Throw,则 Catch[expr, ... ]总是返回expr的值。
form 可以是任何表达式,经常是一个模式。
Throw[value, tag]中的tagform相比较时每次重新计算。 • 参见 Mathematica 全书: 2.5.9.
• 同时参见: Check, CheckAbort.
Further Examples

This function throws overflow if its argument is greater than 10.

In[1]:=  

g[20] throws overflow, which is returned as the value of the enclosing Catch.

In[2]:=  

Out[2]=

In this case, overflow is not generated, and the Catch has no effect.

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.