Download Maple Programming Guide - Numerical Relativity Group at UBC
Transcript
244 • 6 Procedures
The following example illustrates these behaviors:
> Indexed := proc( { `name[1]`::string := "hello",
`name[2]`::string := "goodbye" } )
sprintf("name[1]=\"%s\" -- name[2]=\"%s\"",`name[1]`,`name[2]`)
end proc:
> Indexed(name[1]="hi");
(6.59)
> Indexed(name[1]="bonjour",name[2]="aurevoir");
(6.60)
> Indexed(name[1,2]="good day");
(6.61)
> Indexed(name[2]=42);
Error, invalid input: Indexed expects value for keyword parameter
`name[2]` to be of type string, but received 42
The Special Case of evaln and uneval Modifiers
There is one case in which the first stage of argument processing is not keyword matching.
If the procedure was declared with any parameter(s) having an uneval or evaln modifier,
arguments are first assigned to positional parameters from left to right until the rightmost
uneval or evaln parameter has been bound to an argument or until all the arguments have
been exhausted, whichever happens first. For each argument/parameter pair:
If the parameter has no parameterType, the argument matches trivially, and becomes the
value for that parameter.
If the parameter has a parameterType specification, the argument may or may not match.
If it matches, the argument becomes the value for that parameter. If it does not match, an
exception is raised.
> Accumulate := proc( r::evaln(numeric), n::numeric,
{ operation::symbol := `+` } )
r := operation(eval(r),n)
end proc:
> total := 0:
> Accumulate(total, 2.3);
(6.62)
Related documents
Maple Programming Guide
User Guide - Maplesoft
Maple Introductory Programming Guide
Maple Advanced Programming Guide
A Maple User`s Guide
8XC196KC SPECIFICATION UPDATE
Maple User Manual
PsychoPyManual v1.81.03
Terminal-Emulation (VT100) User Guide and LCD Front
Maple User Manual - University Information & Technology Services
a cas as an assistant to reasoned instrumentation