本章主要展示有关序列的代码参考,比如判断是否是序列、倒取序列成员和子序列、循环取序列成员和子序列、取出子序列但越界不报错、取出第一个非空值、产生由同一成员构成的定长序列、复制(多遍)序列产生新序列、产生连续的数列区间、交换序列的部分成员、在序列中插入(多个)成员、删除序列中的(多个)成员、修改序列的(多个)成员、修改指定位置的序列成员越界则自动补、将序列整个作为成员插入另一序列、字典式比较序列大小、序列倒置、查看和统计序列非重复成员和个数、将序列补足到指定长度、序列逻辑运算等。
|
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],越界成员不出现 |
|
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) |
[3,4,5], 从3到5 |
3 |
=to@s(3,5) |
[3,4,5,6,7],从3起数5个 |
4 |
=to@s(7,-3) |
[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] ,插在后面 |
2 |
=[1,2,3,4].insert(1,5) |
[5,1,2,3,4] ,在前面插 |
3 |
=[1,2,3,4].insert(3,[5,6]) |
[1,2,5,6,3,4] ,插入多个 |
4 |
[1,2,3,4] |
[1,2,3,5,6,4],A5运行后的A4 |
5 |
=A4.insert@n(4,[5,6]) |
[5,6],返回增加的成员 |
|
A |
|
1 |
=[11,12,13,14].delete(2) |
[11,13,14],删除1个 |
2 |
=[11,12,13,14].delete([2,4]) |
[11,13],删除多个 |
|
A |
|
1 |
=[11,12,13,14] |
|
2 |
>A1(2)=6 |
A1的值为 [11,6,13,14] |
3 |
>A1([3,4])=[7,8] |
A1的值为[11,6,7,8] |
4 |
>A1.run(~=~%2) |
A1的值为[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,"a"的ASCII码比"d"小1 |
2 |
=cmp(["d","b","c"],["a","e","f"]) |
1,"d"的ASCII码比"a"大1 |
|
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],去重并排序 |
3 |
=A1.id@o() |
[a,c,d,e,f,a,b],仅去掉相邻重复成员 |
4 |
=A1.id@u() |
[a,c,d,e,f,b],去重保持原序 |
5 |
=A1.icount() |
6,去重后的成员个数 |
6 |
=A1.icount@o() |
7,仅去掉相邻重复成员后的个数 |
|
A |
|
1 |
[a,b,c,d,e,f] |
|
2 |
=A1.pad(null,9) |
[a,b,c,d,e,f,null,null,null],右侧补足 |
3 |
=A1.pad@l(null,9) |
[null,null,null,a,c,d,e,f,a,b],左侧补足 |
|
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 |