Topic 6. Functions. Procedures Expansion Packages. 2D graphics
2. User procedures
Procedure (function) - a set of ads and operators designed to perform a separate logical-designed task.
Procedures are an important element of structural programming and serve as a means of expanding the capabilities of the system Maple by the user.
The procedure for Maple -Mo looks like this:
name: = proc (formal parameters)
expression from formal parameters
end proc
Using the function, related concepts: ad, call and definition.
The ad specifies the name of the function, the type returned by the function, the attributes of its formal parameters.
The formal parameters of a function are variables that take values when a function is called in the sequence of their description of the parameter list.
The formal parameters identifiers should not coincide with the identifiers of the variables declared in the middle of the function body (the local operator).
With the operator:: after the formal parameter, you can specify its type.
For example, in proc (n :: Integer), the n variable is an integer.
The discrepancy between the actual parameters of the type of the specified variables results in an error message and a failure to execute the procedure.
To assign the result of the function of various values and exit from it anywhere, use the return(val) statement.
Procedures may not return any values after their execution.
The body of a function is a composite operator.
In Maple, the variables declared in the function body are local.
The management returns to the call location.
General Procedure:
name: = proc (parameters)
local val1, ..., valn;
if bool1 then RETURN (res1) else expr1; expr2; ... ERROR (`error of procedure`); exprn; fi;
res2;
end;
The function call transfers control and the actual arguments (if any) of a given function.
When performing a function call, the actual arguments are assigned to the corresponding formal arguments.
The transfer of control is passed to the first operator of the body of the function.
Returns the default value of the last operator from the body of the function.
The call is performed by name.
An example, a procedure with the name f , which calculates the sum of the variables x and y :
F: = proc (x, y)
x + y;
end;
Actual arguments can be any values.
The called function works with copies of actual arguments, so no change in the values of formal arguments will affect the change in actual arguments.
The library is being built *. lib functions.
Sum of squares of coordinates
save Sqr, Sqrt "D: \\ ParticleSurf \\ BaseGeom.lib";
Include library in program code.
Font Face
Font Size
Text Colour
Background Colour
Font Kerning
Image Visibility
Letter Spacing
Line Height
Link Highlight