Description:
Get members of a sequence starting from a specified position to create a new sequence.
Syntax:
A.to(a) |
From sequence A, generate a sequence composed of the first a members; when a<0, get members from the (A.len()+1+a)th one to the (A.len())th one |
A.to(a,b) |
From the sequence A, generate a sequence composed of the members from the ath to the bth. If omitting a, then start from the first member by default; if omitting b, get all members of A, that is A.len(), by default, and in this case the comma must not be omitted; if a>b, find the members backwards; members of the newly-generated sequence are ordered in an opposite direction relative to their original order |
Note:
The function generates a sequence composed of the members from the ath to the bth according to sequence A. If omitting a, start from the first member by default; If omitting b, get members to the last one, that is A.len() by default.
Parameter:
A |
A sequence |
a |
The integer specifying the starting position |
b |
The integer specifying the ending position |
Return value:
Sequence
Example:
[1,5,2,6,8].to(2,3) |
Return sequence [5,2]. |
[1,5,2,6,8].to(3,2) |
Return sequence [2,5]. |
[1,5,2,6,8].to(2) |
Return sequence [1,5]. |
[1,5,2,6,8].to(-2) |
Return sequence [6,8]. |
Related function: