/* To exit the innermost block, use return() */ block([n], do ( n: random(20), ldisp(n), if n = 10 then return(), n: random(20), ldisp(n) ) )$ /* To exit any level of block, use catch(...) and throw(); they are not used for catching exceptions, but for non-local return. Use errcatch(...) for exceptions. */ block([n], catch( do ( n: random(20), ldisp(n), if n = 10 then throw('done), n: random(20), ldisp(n) ) ) )$ /* There is also break(, ...) in Maxima. It makes Maxima stop the evaluation and enter a read-eval loop where one can change variable values, then return to the function after exit; For example */ block([x: 1], break(), ldisp(x)); > x: 2; > exit; 2