This chapter lists code examples of handling sequences, including Check if it is a sequence, Get a sequence member or a sub-sequence in reverse direction, Get a sequence member or a sub-sequence in cycles, Get a sub-sequence but report no error if a specified position is beyond range, Generate a fixed-length sequence consisting of duplicate members, Duplicate a sequence (repeatedly) to generate a new sequence, Generate a continuous interger sequence, Exchange positions of member groups of a sequence, Insert one or multiple members to a sequence, Delete one or multiple members from a sequence, Modify one or multiple members of a sequence, Modify sequence member(s) at specified position(s) and supply values at the beyond-range position(s), Insert a sequence as a member into another sequence, Compare sequences in ASCII dictionary mode, Get inversed sequence, Get & count unique members in a sequence, Stretch sequence to specified length and Sequence-related logic operations.
|
A |
|
1 |
=ifa([1,2,3]) |
true |
2 |
=ifa(123) |
false |
|
A |
|
1 |
=[1,2,3,4,5,6].m(-3) |
4 |
2 |
=[1,2,3,4,5,6].m([-2,-3]) |
[5,4] |
|
A |
|
1 |
[1,2,3,4,5,6] |
|
2 |
=A1.m@r(10) |
4 |
3 |
=A1.m@r([1,5,10]) |
[1,5,4] |
|
A |
|
1 |
=[1,2,3,4,5,6].m@0([10,1,4,5]) |
[1,4,5];out-of-range members are not included |
|
A |
|
1 |
=5*[1] |
[1,1,1,1,1] |
2 |
=3.("a") |
[a,a,a] |
|
A |
|
1 |
=[1,2,3] |
|
2 |
=3*A1 |
[1,2,3,1,2,3,1,2,3] |
|
A |
|
1 |
=to(8) |
[1,2,3,4,5,6,7,8] |
2 |
=to(3,5) |
The result is [3,4,5] which is from 3 to 5 |
3 |
=to@s(3,5) |
The result is [3,4,5,6,7] which counts 5 numbers forward from 3 |
4 |
=to@s(7,-3) |
The result is [7,6,5] |
|
A |
|
1 |
=[1,2,3,4,5,6,7,8].swap([2,3,4],[6,7]) |
[1,6,7,5,2,3,4,8] |
|
A |
|
1 |
=[1,2,3,4].insert(0,5) |
[1,2,3,4,5]. Insert the members at the end |
2 |
=[1,2,3,4].insert(1,5) |
[5,1,2,3,4]. Insert the members at the beginning |
3 |
=[1,2,3,4].insert(3,[5,6]) |
[1,2,5,6,3,4]. Insert multiple members |
4 |
[1,2,3,4] |
[1,2,3,5,6,4], the new A4 after A5 is executed |
5 |
=A4.insert@n(4,[5,6]) |
[5,6], return the newly-added member |
|
A |
|
1 |
=[11,12,13,14].delete(2) |
Delete one member and the result is [11,13,14] |
2 |
=[11,12,13,14].delete([2,4]) |
Delete multiple members and the result is [11,13] |
|
A |
|
1 |
=[11,12,13,14] |
|
2 |
>A1(2)=6 |
The value in A1 is [11,6,13,14] |
3 |
>A1([3,4])=[7,8] |
The value in A1 is [11,6,7,8] |
4 |
>A1.run(~=~%2) |
The value in A1 is [1,0,1,0] |
|
A |
|
1 |
=[11,12,13,14,15].modify(2,6) |
[11,6,13,14,15] |
2 |
=[11,12,13,14,15].modify(10,10) |
[11,12,13,14,15,null,null,null,null,10] |
3 |
=[11,12,13,14,15].modify(2,[7,8,9]) |
[11,7,8,9,15] |
|
A |
|
1 |
[1,2,3,4] |
|
2 |
[5,6,7,8] |
|
3 |
=A1.insert(3,[A2]) |
[1,2,[5,6,7,8],3,4] |
|
A |
|
1 |
=cmp(["a","b","c"],["d","e","f"]) |
-1, ASCII code for "a" is 1 less than that for "d" |
2 |
=cmp(["d","b","c"],["a","e","f"]) |
1, ASCII code for "d" is 1 more than that for "a" |
|
A |
|
1 |
[1,3,5,2,4,6] |
|
2 |
=A1.rvs() |
[6,4,2,5,3,1] |
|
A |
|
1 |
=["a","c","d","e","f","a","a","b"] |
|
2 |
=A1.id() |
[a,b,c,d,e,f], remove duplicates and sort members |
3 |
=A1.id@o() |
[a,c,d,e,f,a,b], remove neighboring duplicate only |
4 |
=A1.id@u() |
[a,c,d,e,f,b], remove duplicates but won’t perform sort |
5 |
=A1.icount() |
6, count members after duplicates are deleted |
6 |
=A1.icount@o() |
7, count members after neighboring duplicates are deleted |
|
A |
|
1 |
[a,b,c,d,e,f] |
|
2 |
=A1.pad(null,9) |
[a,b,c,d,e,f,null,null,null], add members on the right side |
3 |
=A1.pad@l(null,9) |
[null,null,null,a,c,d,e,f,a,b], add members on the left side |
|
A |
|
1 |
=[2<10,3>4,1!=1] |
[true,false,false] |
2 |
=A1.cand() |
false |
3 |
=[20,1<2].cand() |
true |
4 |
=[null,1<2].cand() |
false |
5 |
=[1!=1,3<2].cor() |
false |