-
Notifications
You must be signed in to change notification settings - Fork 1
/
u-stl
executable file
·133 lines (101 loc) · 5.05 KB
/
u-stl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# vim:ft=sh nonu
set -o errexit
set -v
# Rg1 >> Rg2 << Rg3
scc -a'range(1,4)' 'vint{1,2} >> dint{3,4}'
scc -a'"abc123"' 'dchar s; "abc" >> s << "123"; '
scc -a'(vint{2,3,2,3})' 'v23 << a23'
scc -a'"abc123"' 's="abc"; s << "123"'
scc -a'"abc123"' 'str("abc")<<"123"'
scc -a"(vint{2,3,'a','b'})" 'v23 << "ab"'
# x << C >> y
scc -a1 'int i,j; dint d3{1,2,3}; i << d3 >> j; i==1 && j==3 && size(d3)==1'
scc -a1 'int i,j; i << dint{1,2,3} >> j; i==1 && j==3 '
scc -a1 'vint v0; int lv=2; v0 << 1 << lv; v0==range(1,2) && (vint{} << 1 << lv) == range(1,2)'
# x >> C << y
scc -a1 '( 1 >> dint{2,3} << 4) == range(1,4)'
scc -a1 '( 1 >> d23 << 4) == range(1,4)'
scc -a1 'int lv=1; dint dk; lv >> (2 >> dk); dk == range(1,2) && (lv >> (2 >> dint{})) == range(1,2)'
# Set << x
scc -a1 'int lv=2; set<int> st; st << 1 << lv; st==range(1,2) && (set<int>() << 1 << lv) == range(1,2)'
# Set << Rt
scc -a1 'set<char> st; (st << "11221133") == "123" && (set<char>{}<<"11221133") == "123"'
# Pair/Tuple
scc -a1 'auto P = pair<int,float>{1,2.0}; ++P == 1 && P++ == 2.0 && size(P)==2'
scc -a1 'auto T = tuple<int,float>{1,2.0}; ++T == 1 && T++ == 2.0 && size(T)==2'
scc -a1 'auto T = MT(1,2,3); ++T == 1 && T++ == 3 && size(T)==3'
# Stack
scc -a1 'stack<int> s; s << 1 << 2 << 3; int x; s >> x; x==3 && s++ == 2 && size(s--)==1'
scc -a1 'dint c{1,2,3,4}; --c; c--; ++c==2 && c++==3'
scc -a1 'map<int,int> m; m << make_pair(1,2); m[1]==2'
scc -a1 'size(-- -- dint{0,1,2,3,4} -- --)==1'
# SIZE
scc -a1 'size(stack<int>() << 1<< 2) == 2 && size(sint{1,2}) == 2 && size(vint{1,2}) == 2 && size(MT(1,2)) == 2'
# EMPTY
scc -a1 '!!v9 && !v0'
# FIND -- Rg / x
scc -a1 'v9 % 3 && ! (v9 % 33) && vint{1,2,3} % 3 && !( vint{1,2,3} % 33)'
scc -a1 'v9 % vint{3,4} && v9 % vint{} && !(v9 % vint{3,444})'
scc 'assert(v9 % [](int i){return i==3;} && !(v9 % [](int i){return i==30;}));'
scc -a1 's9 % "bc" && !(s9 % "n/a")'
scc -a1 '*(v9 / 3) = 33; v9[3]==33'
scc 'copy(v9/2, v9/5, oi)'
scc 'copy(v9/vint{3,4}, v9/vint{8}, oi); endl'
scc -a1 '*(v9 / 3) == 3'
scc '__ v9 / [](int i){return i==3;} - +v9;'
scc '__ *(str("Hello") / [](char c){return c==*"l";});'
scc '*(str("Hello") / islower)'
scc '__ s9 % [](char c){return c==*"b";}, str("Hello") % islower, str("Hello") % isdigit, vs9 % str("bb");'
# BEGIN/ END
scc -a1 '*+v9=42; ++v9==42 && *+vint{1,2}==1'
scc -a1 'const str cS("abc"); cS.begin() == +cS && cS.end() == -cS'
scc -a1 ' str S("abc"); S.begin() == + S && S.end() == - S'
# ACCESS
scc -a1 'char cs[99]="abc"; size(cs)==3 && size("abc")==3 && size(a9)==10 && size(v9)==10'
scc '__ ++range(c9), range(a23)++, ++v9;'
# ERASE
scc 'v9 - (_1%2); v9'
scc 'v9 - 2; v9'
scc 'l9 - 2'
scc 'l9 - (_1%2==0)'
scc 'set<int>{1,2,3} - 2'
scc 'm9 - 2'
scc 'm9 - (_1%2)'
scc 'l9-+l9, v9-+v9, m9-+m9, st9-+st9'
scc 'str("abcd") - "bc"'
scc 'v9 - v23'
scc -a3 "size(str(\"abcd\") - 'b')"
scc -a2 "size(str(\"1abcd2\") - ro::isalpha)"
scc -a3 "dchar s; s << \"abcd123\"; s - ro::isalpha; size(s)"
scc "auto rc9=range(c9); rc9 - 'b'"
# TOFIX scc "auto rc9=range(c9); rc9 - rc9/'b'"
# TODO: ri indexing, and op==
#scc "auto rc9=range(c9); rc9 - rc9/'b'; rc9[1]=='c'"
# GENERICS
scc -a1 'vector<to> V; V.emplace_back(); back(V).instances'
scc '-DZ=v9' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-vint{2,3}, r-front(r), r-begin(r);'
scc '-DZ=l9' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-lint{2,3}, r-front(r), r-begin(r);'
scc '-DZ=a9' '_ front(Z) ,back(Z) ,size(Z);'
scc '-DZ=c9' '_ front(Z) ,back(Z) ,size(Z);'
scc '-DZ=cc9' '_ front(Z) ,back(Z) ,size(Z);'
scc '-DZ=s9' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-str{"12"}, r-front(r), r-begin(r);'
scc '-DZ=st9' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-set<int>{2,3},r-front(r), r-begin(r);'
scc '-DZ=range(c9)' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-front(r);'
scc '-DZ=range(v9)' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-front(r), r-begin(r);'
scc '-DZ=range(l9)' '_ front(Z) ,back(Z) ,size(Z); auto r=Z; _ r-front(r), r-begin(r);'
scc '-DZ=range(9)' '_ front(Z) ,back(Z) ,size(Z);'
scc '-DZ=range(+v9,-v9)' '_ front(Z) ,back(Z) ,size(Z);'
scc '-DZ=range(v9|(_1%2))' '_ front(Z) ,back(Z) ,size(Z);'
scc '-DZ=range(v9*(_1%2))' '_ front(Z) ,back(Z) ,size(Z);'
# Rg1 == Rg2
scc -a1 'vint{} == vint{}'
scc -a1 '"" == vint{}'
scc -a1 'vint{} == ""'
scc -a1 'vint{1} != vint{}'
scc -a1 'vint{1,2,3} != vint{1,2}'
scc -a1 'vint{1,2,3} != vint{1,2,3,4}'
scc -a1 'vint{1,2,3} == vint{1,2,3}'
scc -a1 'vint{1,2,3} == dfloat{1,2,3}'
scc -a1 'vint{1,2,3} == range(1,3)'
scc -a1 'vint{1,2,3} != range(1,4)'
: '- - - - - - - - - - - - - - - - - - - - - - - - U-STL passed - - - - - - - - - - - - - - - - - - - - - - - - -'