m()

Read(2361) Label: m,

Here’s how to use m() function.

A.m ()

Description:

Get members at specified positions.

Syntax:

A.m(i)

n is the lengh of sequence A, -n£i£n and i is not equal to 0; 1<=i<=n indicates getting the ith member; -n<=i<=-1 indicates getting the ith member from the bottom.

A.m(P)

P is a non-zero n-integer sequence.

Note:

A is a sequence whose length is n, from which you get members at specified positions. The function is generally used to get members of a sequence from backwards to forwards.

Parameter:

A

A sequence expression.

i

An integer.

P

A non-zero n-integer sequence.

Option:

@r

Turn back if the specified position exceeds the boundary of A, that is, if the integer i that exceeds the limit of sequence A can be fully divided by n, i is equal to n; otherwise, i is equal to the remainder of i divided by n.

@0

The member represented by a sequence number that exceeds the boundary of A will be excluded from the result.

Return value:

A value or a sequence composed of the members at the specified positions in sequence A

Example:

 

A

 

1

[a,b,c,d,e,f,g,h,i,j]

 

2

=A1.m(2)

b

3

=A1.m(-2)

i

4

=A1.m([2,3])

[b,c]

5

=A1.m([-2,-3])

[i,h]

6

=A1.m@0([5,12])

[e]

7

=A1.m@r([5,12])

[e,b]

Related function:

A.p()

A.m(a:b,c,d:e)

Description:

Get members of a sequence at specified positions to form a new sequence.

Syntax:

A.m(a:b,c,d:e)

Note:

A is a sequence whose length is n, from which you get members at specified positions to form a new sequence, with the condition -n£a£n & a!=0. If 1£a£n, it is the ath member of sequence A when counted from left to right; if -n£ a £-1, it is the ath member of sequence A when counted from right to left. The rules also apply to b, c, d, and e. So, the function is often used to get members of a sequence backwards. The members a and d represent must be respectively on the left side of the members b and e designate. When the parameter on the left side of the colon is omitted, the default value is 1; when the parameter on the right side of the colon is omitted, the default value is -1.

Parameter:

A

A sequence.

a/d

An integer; 1 by default.

b/e

An integer; -1 by default.

c

An integer.

Return value:

Sequence

Example:

 

A

 

1

=to(1,100).m(1:3,9,97:)

[1,2,3,9,97,98,99,100]

2

=to(1,100).m(:5,-1,66:-32)

[1,2,3,4,5,100,66,67,68,69]