Manipulating operands

Up to this point, you have heard of the operands of an operator. We're now going to go into a deep dive of Maple's design: many, but not all, data structures are simply a name followed by a sequence of operands.

You can get the expression or expression sequence that is the operand or operands by using the op(...) function with just that object as an arguemnt. For example:

[> L_1 := [11, 12, 13]:
[> S_1 := {21, 22, 23}:
[> U_F := f(31, 32, 33):
[> op( L_1 );

$11, 12, 13$

[> op( S_1 );

$21, 22, 23$

[> ES := op( U_F );

$ES := 31, 32, 33$

In each case, because there are three objects in the data structure, you get an expression sequence, and as the last example demonstrates, you can assign this expression sequence to another variable.

The philosophy in Maple is that every data structure has zero or more operands, and you can retieve each operand using the op( n, ... ) function where n is a positive integer ($1$, $2$, ...) or negative integer ($-1$, $-2$, ...). For example,

[> op( 1, L_1 );

$11$

[> op( 2, S_1 );

$22$

[> op( -1, U_F );

$ES := 33$

You may note that op( n, ... ) always returns an expression, never an expression sequence, and if n is a negative, it starts from the last operand going to the first.

Next, the first argument of op( m..n, ... ) can also be a range of integers (e.g., 3..5). The first value, m, must refer to one of the operatnds of the second argument, and the next must refer to any operand including or beyond the previous operand referred to by the first integer. All operands from the first and up to and including the second are returned, so if the second refers to the previous entry, then nothing is returned (the NULL expression sequence):

can be positive or negative integers.

[> L_2 := [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]:
[> op( 3..7, L_2 ); # This returns an expression sequence

$33, 34, 35, 36, 37$

[> op( 4..-2, L_2 ); # This returns an expression sequence

$34, 35, 36, 37, 38, 39$

[> op( -5..9, L_2 ); # This returns an expression sequence

$36, 37, 38, 39$

[> op( -5..6, L_2 ); # This returns an expression

$36$

[> op( 4..3, L_2 ); # This returns an the NULL expression sequence

$NULL$

[> op( 1..0, L_2 ); # This returns an the NULL expression sequence

$NULL$