Here’s how to use to() function.
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:
Description:
Generate an integer sequence.
Syntax:
to(a,b) |
Generate a sequence composed of continuous integers between a and b. |
to(n) |
Generate a sequence composed of continuous integers from 1 to n. |
Note:
The function generates a sequence composed of a set of continuous integers from a to b or from 1 to n.
Parameter:
a |
The starting integer. |
b |
The ending integer. |
n |
n>0. |
Option:
@s |
Generate a sequence composed of continuous b integers starting from a. If b is less than 0, generate the sequence backward sequentially in descending order. |
Return value:
A continuous integer sequence
Example:
|
A |
|
1 |
=to(3,7) |
[3,4,5,6,7] |
2 |
=to(5,3) |
[5,4,3] |
3 |
=to(-2,3) |
[-2,-1,0,1,2,3] |
4 |
=to(3,-2) |
[3,2,1,0,-1,-2] |
5 |
=to@s(3,4) |
[3,4,5,6] |
6 |
=to@s(3,-2) |
[3,2] |
7 |
=to(10) |
[1,2,3,4,5,6,7,8,9,10] |
Related function: