PDF-Version - am Institut für Baustatik
PDF-Version - am Institut für Baustatik
PDF-Version - am Institut für Baustatik
Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.
YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.
else<br />
> print(x, `is even non-prime`);<br />
> fi;<br />
> od;<br />
1, is odd non-prime<br />
4, is even non-prime<br />
7, is prime<br />
10, is even non-prime<br />
13, is prime<br />
16, is even non-prime<br />
19, is prime<br />
> printlevel := 1:<br />
11.6.1.3 Break<br />
The syntax of the break statement is simply:<br />
>> break;<br />
The break statement is used in for and while loops to terminate iteration of the loop altogether. Flow of<br />
control resumes with the statement following the body of the loop.<br />
Ex<strong>am</strong>ple:<br />
> printlevel := 0:<br />
> listsum := 0:<br />
> for i in [1,2,3,4,5] do<br />
if i >= 5 then break fi;<br />
> listsum := listsum + i;<br />
> od;<br />
> listsum;<br />
10<br />
> printlevel := 1:<br />
11.6.1.4 Next<br />
The syntax of the next statement is simply:<br />
> next;<br />
The next statement is used in for and while loops to terminate the current iteration of the loop. Flow of<br />
control resumes with evaluation of the loop condition.<br />
Ex<strong>am</strong>ple:<br />
> printlevel := 0:<br />
> listsum := 0;<br />
> for i in [1,2,3,4,5] do<br />
> if type(i, odd) then<br />
> next;<br />
> fi;<br />
> listsum := listsum + i;<br />
> od;<br />
> listsum;<br />
6<br />
> printlevel := 1:<br />
11.6.2 Procedures<br />
Simple one-line functions can be defined with arrow notation as follows:<br />
> f := (x,y) -> x^2 + y^2;<br />
2 2<br />
f := (x,y) -> x + y<br />
121