04.03.2013 Aufrufe

PDF-Version - am Institut für Baustatik

PDF-Version - am Institut für Baustatik

PDF-Version - am Institut für Baustatik

MEHR ANZEIGEN
WENIGER ANZEIGEN

Erfolgreiche ePaper selbst erstellen

Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.

op(tab);<br />

table([<br />

phone = x0-0000<br />

key = 100<br />

n<strong>am</strong>e = joeuser<br />

address = mit<br />

])<br />

The ex<strong>am</strong>ple shows that tables are one of Maple's exceptions to the use of full evaluation. Tables,<br />

arrays, and procedures use what is referred to as "last n<strong>am</strong>e evaluation". In essence, variables access<br />

these objects by reference, not by value. To directly access the value (to copy it, for instance), you<br />

need to use the op function described earlier.<br />

An array is much like a table, except that you specify an integer range of subscripts. For ex<strong>am</strong>ple:<br />

> arr := array(1..2, 1..2);<br />

arr := array(1 .. 2, 1 .. 2, [])<br />

> arr[1,1] := 1: arr[2,2] := 2:<br />

> print(arr);<br />

[ 1 arr[1, 2] ]<br />

[ ]<br />

[ arr[2, 1] 2 ]<br />

11.5.4 Maple Initialization (UNIX)<br />

When a Maple session begins, Maple looks for a file in your home directory called ~/.mapleinit and<br />

reads it in. This provides you with a convenient way to do things like automatically load in packages<br />

that you often use. All you need to do is use a text editor like emacs or ez to create the file<br />

~/.mapleinit. Edit the file and place any Maple commands you want there in the s<strong>am</strong>e format that you<br />

would enter them interactively.<br />

11.6 Progr<strong>am</strong>ming in Maple<br />

Up until this point, discussion has been focused on only two statement types of the Maple language,<br />

the "expression statement" (Ausdrucksanweisung) and the "assignment statement"<br />

(Zuordnungsanweisung). We will now give an overview of some forms of progr<strong>am</strong>ming statements. In<br />

each case, we will give an outline of the syntax of the statement, a description of its meaning or effect,<br />

and an ex<strong>am</strong>ple of its use. For more information on progr<strong>am</strong>ming in Maple, you can refer to the Maple<br />

V Progr<strong>am</strong>ming Guide.<br />

11.6.1 Control Structures<br />

There are four important types of non-procedural statements that affect the flow of control of a<br />

progr<strong>am</strong>:<br />

• the for-while loop<br />

• the if statement<br />

• the break statement<br />

• the next statement<br />

Each of these structures is explained here. There are some other statements that affect flow of control<br />

that have either already been introduced (done/quit/stop), or will be dealt with in the sections<br />

Procedures and Error Handling.<br />

11.6.1.1 For-While<br />

The two syntactic forms of the for-while statement are:<br />

for variable from start by change to finish while<br />

condition do<br />

statement-sequence<br />

119

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!