Language and Programming - Maple Help

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

 Language and Programming

Data Structures

 • Allow double as an alias for float[8]

 $\left[\begin{array}{cc}{0.}& {0.}\\ {0.}& {0.}\end{array}\right]$ (1.1)
 • max/min optionally return position

$\mathrm{max}\left[\mathrm{index}\right]\left(\left[1,2,4,3\right]\right)$

 ${3}$ (1.2)

$\mathrm{min}\left[\mathrm{index}\right]\left(\left[2,1,3,4\right]\right)$

 ${2}$ (1.3)



$\mathrm{max}\left[\mathrm{index},\mathrm{defined}\right]\left(⟨1,2,\mathrm{undefined},5,3⟩\right)$

 ${4}$ (1.4)



Object Inheritance

Objects can now inherit from other object declarations following the usual rules for single inheritance in object-oriented programming.
To inherit from an existing declared object, simply include the name of the parent object in parentheses after the object option in the declaration of the descendant object.

Example: Consider a simple definition of a Vehicle object:

You can derive a subclass of Vehicle called Car which inherits properties from Vehicle simply by including the parent object name in the object option when defining the module:

You can see that a Car is a Vehicle:

 ${\mathrm{true}}$ (2.1)

 ${88}{}⟦{\mathrm{mph}}⟧$ (2.2)

$\mathrm{GetSpeed}\left(\mathrm{myCar}\right)$

 ${88}{}⟦{\mathrm{mph}}⟧$ (2.3)

You can also define other objects, such as Bicycle, which inherit from Vehicle:

Notice that while a Bicycle object is a Vehicle, it is not a Car, just as you would expect:

 ${\mathrm{true}}$ (2.4)

 ${\mathrm{false}}$ (2.5)

Furthermore, if you attempt to access an export such as HasAutomaticTransmission on a Bicycle object, this results in an error, since this export is only provided for a Car object:

$\mathrm{myBike}:-\mathrm{HasAutomaticTransmission}\left(\right)$

$\mathrm{HasAutomaticTransmission}\left(\mathrm{myCar}\right)$

 ${\mathrm{false}}$ (2.6)

cat

 • Enable concatenation of a string with a constant:

 ${"x=2.5"}$ (3.1.1)

rand

 • Allow rand to accept floating-point intervals as input:

 $\left({}\right){→}{\mathrm{RandomTools}}{:-}{\mathrm{Generate}}{}\left({\mathrm{float}}{}\left({'}{\mathrm{range}}{'}{=}{0.}{..}{1.0}{,}{'}{\mathrm{method}}{'}{=}{'}{\mathrm{uniform}}{'}\right)\right)$ (3.2.1)

 ${0.8953600369}$ (3.2.2)

tablemerge

The new command tablemerge allows two tables to be merged together.

 ${\mathrm{table}}\left(\left[{"a"}{=}{150}{,}{"c"}{=}{300}{,}{"b"}{=}{200}\right]\right)$ (3.3.1)

In the resulting table, the value associated to key $"a"$ in T1 was overridden by the value associated to the same key in T2.

If you would prefer they be added, you can specify this by providing a custom merge function:

 ${\mathrm{table}}\left(\left[{"a"}{=}{250}{,}{"c"}{=}{300}{,}{"b"}{=}{200}\right]\right)$ (3.3.2)