invalid subscript selector - 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 : Error Message Guide : invalid subscript selector

Error, invalid subscript selector

 

Description

Examples

Description

This error occurs when you use the selection operation incorrectly when selecting from a list or sequence. For more details, see Selection Operation. Errors due to invalid subscripts are generated by (but not limited to) the following examples.

Examples

Example 1

La,b,c,d,e

L:=a,b,c,d,e

(2.1)

L7

Error, invalid subscript selector

 

Five elements are assigned to list L. This error occurred because the index (subscript in 2-D Math) of the selection operation is out of range for the number of elements in the given list.

 

Solution:

To fix this error, the index should be within the range of the number of list elements.

L2

b

(2.2)

 

Note: Indices are notated using either subscript or square brackets. Both methods will return the same results.

L2

b

(2.3)

 

Example 2

Sw,x,y,z

S:=w,x,y,z

(2.4)

S6

Error, invalid subscript selector

 

In this example, four elements are assigned to sequence S. Negative values can be used for the index, and are used to count the elements starting from the end of the sequence, with -1 being the last item, -2 the second-last item, and so on. This error occurred because the negative index is out of the range of the given number of sequence elements.

 

Solution:

To fix the error, ensure the index (whether positive or negative) is within the range of the number of sequence elements.

S2

y

(2.5)

 

Example 3

L3..8

Error, invalid subscript selector

 

Ranges (a..b) can be used for selecting elements, but they must be within range of the number of list elements. This error occurred because the range endpoint (8) of the index is out of range of the number of list elements.

 

Solution:

L3..5

c,d,e

(2.6)

 

Example 4

L4..2

Error, invalid subscript selector

 

If the index is a range of positive integers, the lower bound must be less than or equal to one more than the upper bound. Specifically, A3..3 selects a single element, A3..2 produces an empty selection, and A3..1 is not permitted. Negative integers in a range are first converted to equivalent positive integers, then this requirement is imposed.

 

Solution:

L5..5

e

(2.7)

L4..3

(2.8)

L1..2

(2.9)

 

Example 5

S1.2

Error, invalid subscript selector

 

The index of the selection operation must evaluate to an integer, a range, or NULL. This error occurred because the index is a non-integer. This could also be a syntax error; ranges must include two periods.

 

Solution:

S1

w

(2.10)

S1..2

w,x

(2.11)

S

w,x,y,z

(2.12)

See Also

list

range

selection

sequence