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.
:= 2;<br />
> print(`a:`, a, ` eval a:`, eval(a), ` a:`, a);<br />
> end:<br />
> g(2);<br />
2<br />
b + 2<br />
2 2<br />
a:, b + 2, eval a:, 6, a:, b + 2<br />
> # So full evaluation doesn't happen to local variable "a", even<br />
> # if evaluation is called. You'd have to assign the result of<br />
> # "eval(a)" to "a" to update its value.<br />
> a;<br />
0<br />
> # Just to check, the global variable "a" is not affected by<br />
> # the local variable "a" in function "g".<br />
11.6.2.2 Options<br />
Options are used to control run-time behaviour of a procedure. The options defined for Maple V are<br />
builtin, remember, system, operator, and trace. remember is the one of greatest use to most users.<br />
When you use option remember, the values that correspond to particular par<strong>am</strong>eter lists are stored for<br />
future use. This way they can be retrieved instead of recalculated, a feature particularly useful for<br />
recursive function implementations.<br />
You can force remember for particular argument values, whether or not option remember has been<br />
specified. You simply perform an assignment to the function with the appropriate par<strong>am</strong>eter value. For<br />
ex<strong>am</strong>ple:<br />
> h(2) := 3;<br />
h(2) := 3<br />
> h(2);<br />
3<br />
This is why it is necessary to use proc to define functions. It is tempting to try syntactic definitions like<br />
m(x) := x^2, but what you are really doing is stating something like "the value of function m at the<br />
string `x` has the value `x`^2", assuming "x" was a mathematical variable when you entered in the<br />
assignment statement. When you try to plot this pseudo-function, you will find that some forms of<br />
plotting (like par<strong>am</strong>eterized 3-D plotting) do not work.<br />
11.6.2.3 Explicit RETURN<br />
The syntax of the RETURN statement is simply:<br />
RETURN(value);<br />
This causes the procedure to terminate, returning the value specified.<br />
11.7 Error Handling<br />
There are three facilities for error handling in Maple: ERROR, lasterror, and traperror.<br />
11.7.1 ERROR<br />
The ERROR statement is used for error return. Its syntax is simply:<br />
ERROR(error-message-string);<br />
The "ERROR" must be in capital letters. When you use ERROR in procedures to indicate that<br />
something has gone wrong, you will see a message printed of the form:<br />
Error, (in procn<strong>am</strong>e) error-message-string<br />
123