The Selection Operation - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Sets and lists : selection

The Selection Operation

Calling Sequence

A[expr]

Parameters

A

-

name, table, list, set, string, or expression sequence

expr

-

expression

Description

• 

The selection operation  can be used to select components from an aggregate object.

• 

If A evaluates to an unassigned name then the selection operation yields an indexed name.

• 

If A evaluates to a table then the selection operation is the standard table indexing operation.

• 

If A evaluates to an hfarray the selection operation yields either a Maple float (if the number of indices matches the number of dimensions of the hfarray), or a sub-hfarray (if the number of indices is less than the number of dimensions).

• 

If A evaluates to a list, set, or expression sequence, then the argument expr must evaluate to an integer, a range, a sequence of integers or NULL.

• 

If A evaluates to a string, then A[expr] is equivalent to substring(A,expr).

• 

If expr evaluates to an integer i, then the i^th element is returned.

• 

If A evaluates to a list, set, or expression sequence, and expr evaluates to a range, then a list, set, or expression sequence of the elements specified by the range is returned.  If the list, set or sequence contains sublists or subsets, then expr can be an expression sequence, in which case the appropriate subentry will be returned.

• 

If A evaluates to a table, and expr evaluates to a range, then the selection remains unevaluated.

• 

Negative integers can appear in expr. In this case, elements are counted from the end of the list, set, or expression sequence. The -1^th element is the last element, the -2^th element is the second last, and so on.

• 

If expr evaluates to 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.

• 

If expr evaluates to NULL, then an expression sequence of all elements is returned unless A is a string, in which case A[] is returned.

Examples

L:=a,b,c:

L1

a

(1)

L1..2

a,b

(2)

L2..1

b,c

(3)

L3..3

c

(4)

L3..2

(5)

The following would lead to a selection of length -1, and so is not legal:

L3..1

Error, invalid subscript selector

X:=L[]

X:=a,b,c

(6)

X1

a

(7)

X1..2

a,b

(8)

X2..1

b,c

(9)

L:=1,2,3,4,5,6,7,8,9

L:=1,2,3,4,5,6,7,8,9

(10)

L3,2,1

5

(11)

S:=a,b,c

S:=a,b,c

(12)

S1

a

(13)

S1..2

a,b

(14)

S2..1

b,c

(15)

T1:=a:T2:=b:T3:=c:

T1

a

(16)

T1..2

T1..2

(17)

T2..1

T2..1

(18)

S:=a string

S:=a string

(19)

S1

a

(20)

S1..2

a

(21)

S2..1

ng

(22)

See Also

exprseq, indexed, list, name, op, set, string, StringTools[SubString], substring, table, type[indexable]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam