Language and Programming
Maple 2018 includes the following enhancements to the Maple language and programming facilities.
Coding in Maple
Until Clause in For Loops
Compare the Value and Structure of Expressions
select, remove, and selectremove
Code Edit Regions
There are numerous upgrades and enhancements for Code Edit Region embedded components.
Visual updates include the code edit region's width automatically fits the entire window.
Code edit regions automatically display command completion lists.
It is now possible to cursor into and out of code edit regions. Previously the only way to enter a code edit region was using the mouse.
The Code Editor (Startup code and Embedded Component code) has also been updated with several new features and several usability improvements. To access the Startup code editor, click on the gears icon (
) on the Maple toolbar.
A new console window at the bottom of the code editor makes it possible to test the startup code from directly inside the code editor.
Using maplemint, the code editor gives a greater level of information about programming errors.
The code editor automatically displays command completion lists.
Errors are now shown inline and the code editor displays a notification strip for errors in the scroll bar on the right side of the window.
Automatic text wrapping improves readability.
Menu items were added for cut, copy, paste, undo, and redo.
mint and maplemint
mint and maplemint generate static analysis information for procedures, giving parameter naming conflicts, unreachable code, unused parameters or variables, and more. The mint.exe tool is available for use with text files that contain Maple code, and maplemint() is a command that can be given Maple procedures to analyze.
a:=proc() local b,i;
while (b>0) do
for i from 1 to 6 do
for i in [1,3,5] do
These names were used as global names but were not declared: %d, test
There is unreachable code following a break statement at statement 5:
There is unreachable code following a break statement at statement 9:
In Maple 2018 the implementation of the external mint.exe tool was merged together with the maplemint() command so they could both analyze code in the same way. As a result, the maplemint() command now works on modules and reports a wider class of warnings, and the external tool now supports the following new warnings:
m := module()
export p1 := proc( x )
export p2 := proc( y )
local a, b;
a := b*y;
b := 42;
a + b;
export p3 := proc( z )
Nested Procedure p1( x ) on lines 1 to 2
These global variables were declared, but never used: G
Nested Procedure p2( y ) on lines 3 to 4
These local variables were used before they were assigned a value: b
Nested Procedure p3( z ) on lines 5 to 6
Ineffectual call to with() inside a proc at statement 1: with(LinearAlgebra)
Assignments can now be used as, or embedded within, expressions. The assignment must be enclosed in parentheses. The result of the assignment is the evaluated right-hand side.
g := x -> (x-1,x+1);
g((z := 2));
An optional until clause has been added to Maple's loop control structure. When used, this clause is written in place of end do, and consists of the keyword until, followed by a Boolean expression. When the expression evaluates to true after the loop's body has executed, the loop terminates.
Since the until clause is checked at the end of the loop, a loop with an until clause and no other terminating condition (a to or while part) will execute its body at least once.
For example, find the next prime after a given number using the isprime function.
n := 37;
do n := n+1 until
DecodeEntities and EncodeEntities encode and decode strings with HTML entities.
r := DecodeEntities("エンコード");
r := EncodeEntities( r ): lprint(r);
SameStructure accepts two expressions, inert or otherwise, and compares their structure. If they are the same in value and structure then this command returns true, otherwise false.
SameStructure(y = 1-x, y = 1-x)
SameStructure(1-x = y, y = 1-x)
The select, remove, and selectremove commands can now perform substitutions in-place in Arrays, Matrices, Vectors, tables, and objects. This functionality is specified by appending inplace as an index to the command name.
When selectremove[inplace] is called, the first result is computed in-place, and the removed elements are returned in a new container that is returned as the second result.
selectremove[inplace](type, [1,2,3,4,5,6,7,8,9], odd);
For details, see select.
Object overloading of the select, remove, and selectremove functions, as well as andmap and ormap, is now supported. For details, see object/builtins.
The RandomTools:-Generate command offers a new flavor called variable, and adds an exclude option to RandomTools:-Generate(integer(...)).
The new RandomTools:-RandomExpand command produces a new expression in expanded form that is equivalent to the given expression.
Download Help Document