Changes to the Maple Language in Maple V Release 5
|
Several changes and improvements have been made to the Maple programming language and system. A brief description of these changes and improvements follows.
|
|
Lexical scoping
|
|
•
|
Maple V Release 5 implements lexical scoping.
|
|
|
Strings
|
|
•
|
A new feature of Maple is the ability to create strings. More information about strings is available in highlights, and examples have been provided in the strings example worksheet .
|
•
|
Because strings require double quotation marks, the recall operator in Maple V Release 5, formerly written as ", is now written as %. Similarly, "" and """ become %% and %%%, respectively.
|
•
|
Strings may be converted to names (or symbols) using the convert command.
|
>
|
convert( "A string", 'symbol' );
|
•
|
The percent character is reserved for system-defined names. Users should not use % at the beginning of a name.
|
|
|
Multiple Assignment
|
|
•
|
Multiple assignments can be made in a single Maple instruction in Release 5.
|
>
|
ll := ["a", 1, "b", 2, "c", 3, "d" ];
|
| (7) |
>
|
strings, numbers := select( type, ll, 'string' ), remove( type, ll, 'string' ):
|
| (8) |
|
|
:
|
|
•
|
The typematch operator ::, used frequently to provide for automatic type checking of arguments to procedures, used to be called :.
|
•
|
Use of the single colon form of the typematch operator is no longer supported in Release 5. (A warning was issued in Release 4; now, it is an error.)
|
|
|
Other Language Changes
|
|
•
|
The exponentiation operator `^` is now a function; this affects type.
|
•
|
The following operators are now also functions: `<`, `<=`, `>`, `>=`, `=`, `<>`
|
•
|
Allow checking for the types assigned to unevaluated names.
|
>
|
type( 'a', name( integer ) );
|
>
|
type( 'a', name( float ) );
|
•
|
Expressions of the following forms are now acceptable input.
|
|
|
New Functions and Types
|
|
|
Functions
|
|
|
Several new system level procedures have been added.
|
•
|
The new function nprintf is like sprintf, but it returns a name instead of a string.
|
>
|
nprintf( "The value of \"a\" is %d\n", a );
|
| (20) |
>
|
sprintf( "The value of \"a\" is %d\n", a );
|
| (21) |
•
|
Use the procedure timelimit to limit the amount of CPU time spent on a computation.
|
>
|
f := proc(n::posint)
local i;
for i from 1 to n do
2^i;
od;
end;
|
| (22) |
>
|
timelimit( 3, f( 10^6 ) );
|
Error, (in f) time expired
|
|
|
•
|
Operating system environment variables (on platforms that have them) can be retrieved using the new procedure getenv.
|
/u/maple/research/bin:/usr/bin:/usr/openwin/bin:/usr/ucb:/usr/local/bin
|
|
|
•
|
The current directory of the Maple process can be queried, or set (on platforms that support this), using the procedure currentdir.
|
>
|
currentdir( "/" ): # old working directory is returned
|
>
|
currentdir(); # print cwd
|
•
|
A new format %A has been added to printf. It is essentially the same as the %a format except that backquotes are not put around names even though they might need it to be valid maple input.
|
|
|
Types
|
|
•
|
The new type constructors And, Or, and Not allow you to construct new types from existing types by means of boolean combinations, or to test directly for boolean combinations of type.
|
>
|
type( Pi, 'And( constant, numeric )' );
|
>
|
type( Pi, 'And( constant, Not( numeric ) )' );
|
>
|
type( 3.14, 'And( constant, numeric )' );
|
>
|
`type/stringythingy` := 'Or( string, name )';
|
| (27) |
>
|
type( `foo`, 'stringythingy' );
|
>
|
type( "bar", 'stringythingy' );
|
>
|
type( 27, 'stringythingy' );
|
•
|
Use the new type arctrigh to test for an expression that is a call to an inverse hyperbolic function.
|
>
|
type( sin( x ), 'arctrigh' );
|
>
|
type( arcsin( x ), 'arctrigh' );
|
>
|
type( sinh( x ), 'arctrigh' );
|
>
|
type( arcsinh( x ), 'arctrigh' );
|
•
|
An optional additional argument allows you to check that the expression is an inverse hyperbolic function of some name.
|
>
|
type( arctanh( 2 * sin( x / y ) ), 'arctrigh( x )' );
|
>
|
type( arctanh( 2 * sin( x / y ) ), 'arctrigh( t )' );
|
>
|
type( a[i], 'atomic' );
|
>
|
type( "a string", 'atomic' );
|
>
|
type( ( x + y ) * z, 'atomic' );
|
•
|
If evalf returns a number of the form a + b * I, with a and b floating point numbers, or if evalf returns infinity or -infinity, then the solution is of type complex constant, called complexcons.
|
>
|
type( -infinity, 'complexcons' );
|
>
|
type( arcsinh( 1 + I ), 'And( complexcons, arctrigh )' );
|
•
|
Arrays of hardware floating point numbers (hfarrays) are new in Maple V Release 5. They are of type hfarray.
|
| (44) |
>
|
type( "a short string", 'literal' );
|
>
|
type( 1/5, 'literal' );
|
>
|
type( M[2,3], 'literal' );
|
•
|
An integer that is not positive, nonposint, is a new Maple type introduced in this release.
|
>
|
type( 2, 'nonposint' );
|
>
|
type( 0, 'nonposint' );
|
>
|
type( -1, 'nonposint' );
|
>
|
type( -2/3, 'nonposint' );
|
>
|
type( -infinity, 'nonposint' );
|
>
|
type( infinity, 'nonposint' );
|
•
|
range -- check for a range
|
•
|
A new type constructor, Range, allows you to construct a "type" that determines whether an object lies in a specified numeric range.
|
>
|
type( 2, 'Range( 1, 3 )' );
|
>
|
type( 5, 'Range( 1, 3 )' );
|
•
|
A number that is algebraic and is expressed as a Maple radical or using RootOf notation is of type radalgnum.
|
>
|
map( type, [ 2/7, evalf( Pi ), RootOf( x^2 + 1 ), RootOf( z^2 - x, z ) ], 'radalgnum' );
|
| (58) |
•
|
You can test whether an expression is a radical algebraic function of its indeterminates, or of a specified set of indeterminates, using a type test against the type radalgfun.
|
>
|
type( sin( x ), 'trigh' );
|
>
|
type( tanh( x ), 'trigh' );
|
>
|
type( arcsech( coth( x ) ), 'trigh' );
|
•
|
Use the new Maple type symbol to test whether an object is a symbol. A symbol is a name that is not of type indexed
|
|
|
|
System
|
|
|
Debugging
|
|
•
|
Parser generated warnings now have line numbers.
|
•
|
Tracing of builtin functions is now fully implemented.
|
•
|
The tracelast command now gives line numbers (in a format that you can cut and paste to the stopat command).
|
•
|
The tracelast command will tell you where a computation was interrupted by the user.
|
|
stoperror(interrupted); ,
|
|
stoperror("time expired"); ,
|
|
stoperror("assertion failed"); ,
|
|
stoperror("invalid argument"); .
|
•
|
The debugger has a where function that shows the call stack of a stopped procedure.
|
•
|
There is a new WARNING function that users can use to issue warnings in their own procedures.
|
>
|
f := proc(x::integer)
if x < 0 then
WARNING( sprintf( "negative argument passed to %s", procname ) );
fi;
2*x;
end:
|
•
|
The new kernelopts(dagtag) option maps between internal data structure IDs and their names.
|
>
|
kernelopts( dagtag = PROC );
|
>
|
kernelopts( dagtag = 1 );
|
>
|
seq( kernelopts( dagtag = i ), i = 1..46 );
|
| (67) |
•
|
A detailed account of the storage being used by objects of different types can be obtained using kernelopts(memusage).
|
•
|
The directory separator, as a string, used on the particular platform that Maple is running on, can be queried using kernelopts(dirsep).
|
|
|
User Interface
|
|
•
|
The new interface(autoassign) variable controls whether the context-sensitive menus automatically generate an assignment for the results of a menu operation, and what variable name it uses if this feature is used.
|
•
|
Command completion has been reenabled (see editing, and the lib/cmds file).
|
•
|
Maple quits on reaching end of file. Use the -F option to recover the old behavior, which allows you to continue interactively after the end of the input file has been reached.
|
•
|
Input files can now be specified as command line arguments of the maple command. It is no longer necessary to write maple < file, using shell redirection. (See the man page.)
|
•
|
The help system in the TTY version now returns near-matches if an exact match was not found.
|
No exact matches found, please try one of the following:
|
eval
|
evala
|
evalapply
|
evalb
|
evalc
|
evalf
|
evalfint
|
evalgf
|
evalhf
|
evalm
|
evaln
|
evalr
|
evalrC
|
>
|
|
|
•
|
An alternate initialization file may be specified on the command line, using the new -i option.
|
|
For example, if you use the Korn shell, you can use the alias alias maplev5="maplev5 -i $HOME/.maplev5.init" to ensure that your new version of Maple uses the correct initialization file.
|
|
|
Performance
|
|
•
|
Karatsuba's algorithm is used for multiplying large integers.
|
•
|
Use of hardware floating point arrays (hfarrays) improves performance dramatically in some areas (such as plotting).
|
•
|
Profiling of the kernel has been done, and significant performance improvements were implemented as a result of finding some bottlenecks.
|
|
|
|