Examples of Maple Objects - Maple Programming Help

Home : Support : Online Help : Create Maple Worksheets : Enter Expressions : worksheet/expressions/mathobjects

Examples of Maple Objects

 You may need these Maple objects when solving mathematical problems.

Expression Sequences

 An expression sequence is a group of Maple expressions separated by commas. Expression sequences preserve the order and the repetition of their elements.
 > a, b, b, c, b, a;
 ${a}{,}{b}{,}{b}{,}{c}{,}{b}{,}{a}$ (1)

Lists

 A list is a collection of objects separated by commas and enclosed in square brackets. Maple preserves the order and repetition of items in a list. As a result, you can extract a particular element from a list.
 > marks := [92,86,91,76,83,88,85,90,88,79,81];
 ${\mathrm{marks}}{:=}\left[{92}{,}{86}{,}{91}{,}{76}{,}{83}{,}{88}{,}{85}{,}{90}{,}{88}{,}{79}{,}{81}\right]$ (2)
 > marks[2];
 ${86}$ (3)

Sets

 A set is a collection of objects enclosed in braces. Maple preserves neither order nor repetition in a set; therefore these three sets are equivalent.
 > {a,b,c},{c,a,b},{a,a,b,c,a};
 $\left\{{a}{,}{b}{,}{c}\right\}{,}\left\{{a}{,}{b}{,}{c}\right\}{,}\left\{{a}{,}{b}{,}{c}\right\}$ (4)

Arrays

 An Array is a multidimensional data structure which can be indexed by integer ranges. The following is an Array of powers of 2.
 > powers_of_two:= Array( 1..4, [2,4,8,16] );
 ${\mathrm{powers_of_two}}{:=}\left[\begin{array}{cccc}{2}& {4}& {8}& {16}\end{array}\right]$ (5)
 > powers_of_two[3];
 ${8}$ (6)

Tables

 A table is similar to an array, but it can have anything as indices, not just integers.
 > translate:= table([one=eins, two=zwei, three=drei]);
 ${\mathrm{translate}}{:=}{\mathrm{table}}\left(\left[{\mathrm{two}}{=}{\mathrm{zwei}}{,}{\mathrm{one}}{=}{\mathrm{eins}}{,}{\mathrm{three}}{=}{\mathrm{drei}}\right]\right)$ (7)
 > translate[two];
 ${\mathrm{zwei}}$ (8)

Strings

 A string is a sequence of characters that has no value other than itself. It is created by enclosing a string of characters within a pair of double-quotes.
 > astring:="This is a string.";
 ${\mathrm{astring}}{:=}{"This is a string."}$ (9)
 > astring[11..16];
 ${"string"}$ (10)