Language and Programming - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Information : Updates : Maple 2017 : Language and Programming

Language and Programming

Maple 2017 includes the following enhancements to Maple language and programming facilities.

 

Improvements to Debugging Facilities

New Commands

Updated Commands

Improvements to Debugging Facilities

Debugging with Source Code

The function showsource (and the corresponding debugger command of the same name) takes a procedure name and statement number or range thereof, and displays the source line(s) corresponding to the specified statement(s). The lines are displayed preceded by one or two numbers, the first being the source line number, and the second being the statement number if the source line corresponds to a statement. See showsource.

The existing function and debugger command, stopat, can be used to set breakpoints based on source line numbers by calling it in the form, stopat(filePathString,lineNums), where filePathString is a string (instead of a procedure name). See stopat.

Note that to do source level debugging, you must have the source. You cannot do source debugging on libraries provided only in .mla format (such as the libraries that ship with Maple).

Inspecting Variables on the Maple Stack

The inspect debugger command is a general purpose command for inspecting the current state of the procedure activation stack. It can be used to inspect parameters, local variables, and the code of currently active procedures. See the inspect command in debugger.

In support of the inspect command, the output of the where debugger command (which shows the activation stack) now has numbered separating lines between the displayed stack levels.

Counted Breakpoints

The stopat function and debugger command can now be passed an integer (N) or range of integers (N..M) for its optional condition argument. This specifies that the debugger should be invoked only the Nth (through Mth) time that the specified statement is executed. See stopat.

Depth-limited Tracing

The trace function now takes an optional keyword argument, depth=N, where N is an integer, and limits tracing to N levels of invocation of the specified procedure. This makes it easier to trace highly recursive procedures when only the top few levels are of interest.

Miscellaneous Changes and Improvements

The output of showstat now respects the settings of interface(indentamount) and interface(longdelim).

New Commands

index

The index command constructs an indexed expression. The calling sequence indexf,x is equivalent to constructing the expression fx.

index( f, x );

fx

(2.1.1)

If the first argument, f, is an indexable expression, then the index command returns the result of indexing the first argument by the second argument:

index( [a, b, c ], 2 );

b

(2.1.2)

MTM:-unwrap

The MTM:-unwrap command modifies phase angles in radians in the array M by adding integer multiples of 2Pi to ensure the difference between consecutive elements in the result is less than Pi.

A := <3.8699, 0.62832, -1.2566, 0>;

A3.86990.62832−1.25660

(2.2.1)

MTM:-unwrap( A );

3.86996.9115053085.0265853086.283185308

(2.2.2)

verify/wildcard

The verify/wildcard command verifies a relation between two expressions, independent of variable names.

For example, the following returns true because both expressions contain a single name and substituting y for x in the first expression yields the second:

verify(x^2-x, y^2-y, wildcard)

true

(2.3.1)

Updated Commands

andmap and ormap

Maple uses three-valued logic (true, false, FAIL) for its Boolean operators. The commands andmap and ormap now use the same three-valued logic. For example, the following returns FAIL because true and FAIL evaluates to FAIL.

andmap(x->evalb(x<4),[3,I])

FAIL

(3.1.1)

In prior versions of Maple, this example raised an exception.

Improvements to max and min

When programming with max and min, you now have a new way to handle cases when the function is called with no arguments or only empty container arguments.  You can now opt to have max (or min) return NULL in those cases instead of negative (or positive) infinity by using the index nodefault.

min();

(3.2.1)

min[nodefault]();

Sorting of Data Frames, Data Series, and Objects

You can now sort data frames and data series.  For details, see DataFrame/sort and DataSeries/sort.

Additionally, object overloading of the sort function is now supported.  For details, see object/builtins.