Error, invalid subscript selector - Maple Programming Help

Home : Support : Online Help : System : Error Message Guide : invalidsubscriptselector

Error, invalid subscript selector

 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

 > $L≔\left[a,b,c,d,e\right]$
 ${L}{:=}\left[{a}{,}{b}{,}{c}{,}{d}{,}{e}\right]$ (2.1)
 > ${L}_{7}$

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.

 > ${L}_{2}$
 ${b}$ (2.2)

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

 > $L\left[2\right]$
 ${b}$ (2.3)

Example 2

 > $S≔w,x,y,z$
 ${S}{:=}{w}{,}{x}{,}{y}{,}{z}$ (2.4)
 > ${S}_{-6}$

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.

 > ${S}_{-2}$
 ${y}$ (2.5)

Example 3

 > ${L}_{3..8}$

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:

 > ${L}_{3..5}$
 $\left[{c}{,}{d}{,}{e}\right]$ (2.6)

Example 4

 > $L\left[4..2\right]$

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, ${A}_{3..3}$ selects a single element, ${A}_{3..2}$ produces an empty selection, and ${A}_{3..1}$ is not permitted. Negative integers in a range are first converted to equivalent positive integers, then this requirement is imposed.

Solution:

 > $L\left[5..5\right]$
 $\left[{e}\right]$ (2.7)
 > $L\left[4..3\right]$
 $\left[{}\right]$ (2.8)
 > $L\left[-1..-2\right]$
 $\left[{}\right]$ (2.9)

Example 5

 > ${S}_{1.2}$

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:

 > ${S}_{1}$
 ${w}$ (2.10)
 > ${S}_{1..2}$
 ${w}{,}{x}$ (2.11)
 > ${S}_{\left[\right]}$
 ${w}{,}{x}{,}{y}{,}{z}$ (2.12)