How can I exit multiple nested loops? Break[] exits nearest loop only.
For[j = 1, j <= 10, j++, For[i = 1, i <= 10, i++, If[i == 3 && j == 4, Break[]] ]]; Print[i, j]
(how to delete the post? :))
It is not that those commands are not good but those commands were put in Mathematica version one so that people coming from a strictly procedural background dating all the way back to the beginning of Fortran would have a simple entry point into Mathematica and then move on to the more powerful constructs of the wolfram language. In the Mathematica there is always a much clearer and more powerful approach using functional and rule-based programming.
Thanks. What's the reason the commands you mentioned aren't as good as Throw Catch?
Throw Catch
Throw and Catch.
But perhaps you would like to move away from ancient procedural programming constructs. And things like Break, Return, GoTo, and so on are the stuff of original Fortran and Basic.
That will terminate whole computation, not just exit the nested loop.
Abort?