# Maple/Sequences, lists, sets, and tables in Maple

In comparison to the standard description of arrays in other languages, the variety of ways to group several elements into a single object in Maple may look a little bit tricky.

If one plots (see Graphic functions) several functions at the same graphic, the correct sequence may have, for example the form

plot([sin(x),cos(x)],x=0..9);

By default, the first function will be plotted with red, second with green, thirds with yellow (almost invisible at the white background) and so on. The similar if can be obtained with

plot({sin(x),cos(x)},x=0..9);

but then the color become dependent on the values of the functions.

Compare, for example,

[1,2,3,4,5,4,3,2,1]

to

{1,2,3,4,5,4,3,2,1}

In the first case, a list, the sequence remains the form in which it was typed; in the second case, a set, duplicates are removed and the original order is forgotten.

### Sequence edit

The sequence of element can be generated with function seq. Example of use:

seq( n^2, n=-2 .. 2 );

generates

4, 1, 0, 1, 4

Sequences are spliced within the argument list where they occur. This makes seq a rather general tool for writing various kinds of container literals:

foo(5, seq(n^2, n=-2..2), 5); # foo(5, 4, 1, 0, 1, 4, 5); [5, seq(n^2, n=-2..2), 5]; # [5, 4, 1, 0, 1, 4, 5]; {5, seq(n^2, n=-2..2), 5}; # {0, 1, 4, 5};

The way of evaluation of expressions may be a little bit different from that we could expect in the command line; compare, for example, outputs of
> seq\sin(x) , n = -2 .. 2/

which gives 1/sin(x)^2, 1/sin(x), 1, sin(x), sin(x)^2

and sin^(-2)(x), sin^(-1)(x), sin^0(x), sin^1(x), sin^2(x)

1/sin(x)^2, arcsin(x), sin(x), sin(x), sin(x)^2

which gives

(1/sin^2)(x), (1/sin)(x), 1(x), sin(x), (sin^2)(x)