A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
36
Task/Loops-Break/Maxima/loops-break.maxima
Normal file
36
Task/Loops-Break/Maxima/loops-break.maxima
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* To exit the innermost block, use return(<value>) */
|
||||
|
||||
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(<value>);
|
||||
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(<value>, ...) 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue