BUILT-IN MATHEMATICA SYMBOL
stops evaluation and returns value as the value of the nearest enclosing Catch.
is caught only by Catch[expr, form] where form is a pattern that matches tag.
- You can use Throw and Catch to exit functions such as Nest, Fold, FixedPoint, and Scan.
- tag can be any expression.
- tag in Throw[value, tag] is re-evaluated every time it is compared to form in Catch[expr, form].
- An error is generated and an unevaluated Throw is returned if there is no appropriate enclosing Catch to catch the Throw.
Exit to the enclosing Catch as soon as Throw is evaluated:
Define a function that can "throw an exception":
The result of Catch is just what is thrown by Throw:
Use Throw to exit a loop when a criterion is satisfied:
New in 1 | Last modified in 3