-
Notifications
You must be signed in to change notification settings - Fork 1
/
u-basic-range
executable file
·78 lines (58 loc) · 3.35 KB
/
u-basic-range
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
# vim:ft=sh nonu
set -o errexit
set -v
################################################################# BASIC_RANGE
# CTOR
scc 'basic_range<vint&> lv(v9); basic_range<vint&&> rv(mk_v9());'
#scc 'auto r = range(range(v9)); auto rr=range(range(mk_v9())); assert(r.size()==rr.size());'
scc -A -DV=rl9 'V.begin(); +V; V.end(); end(V); endz(V); -V; _ ++V, V.front(), front(V), V++, V.back(), back(V), V.size(), size(V), V.empty(), empty(V), bool(V);'
scc -A -DV=rd9 'V.begin(); +V; V.end(); end(V); endz(V); -V; _ ++V, V.front(), front(V), V++, V.back(), back(V), V.size(), size(V), V.empty(), empty(V), bool(V);'
scc -A -DV=rd9r 'V.begin(); +V; V.end(); end(V); endz(V); -V; _ ++V, V.front(), front(V), V++, V.back(), back(V), V.size(), size(V), V.empty(), empty(V), bool(V);'
scc -A -DV=rrd9 'V.begin(); +V; V.end(); end(V); endz(V); -V; _ ++V, V.front(), front(V), V++, V.back(), back(V), V.size(), size(V), V.empty(), empty(V), bool(V);'
scc -A -DV=n9 'V.begin(); +V; V.end(); end(V); endz(V); ; _ ++V, V.front(), front(V), V++, V.back(), back(V), V.size(), size(V), V.empty(), empty(V), bool(V);'
# access
scc -a1 'rd9++==9 && ++rd9==0'
scc 'auto r = range(v9); while(r) { _ v9++; v9--; };'
scc 'auto r = range(v9); __ r.back(), r++; r.back() =99; r'
# Imported methods
scc -a1 'auto r=range(vint{}); r.push_back(1); r << 2; range(r) << 3; size(r)==3'
# Iterators
scc 'rd9.begin(); rrd9.begin(); '
scc 'auto it=+rd9; decltype(rd9)::const_iterator cit=+rd9; assert( it==cit && ++it != cit && -rd9 == endz(rd9));'
scc 'assert( 1 == (*(+rd9 += 1) * *(+rd9 + 1) * *(1 + +rd9) * *(-rd9-size(rd9)+1) * *(-rd9 -= size(rd9)-1) * (size(rd9) == size_t(-rd9 - +rd9)) * (+rd9)[1] * rd9[1]));'
scc 'assert(+rd9 < -rd9 && !(+rd9 < +rd9) && !(-rd9 < +rd9) && -rd9 >= +rd9 && -rd9 >= -rd9 && !(+rd9 >= -rd9));'
scc 'vector<pair<int,double>> V={{1,11.},{2,22}}; auto r=range(V); _ (-- ++ (+r +=1))->second;'
scc 'auto i=+rd9, ii=i+1; *i, *ii'
scc ' if (rv9/3) *(rv9/3) = 33; rv9'
# rg = value_type
scc -a1 'range(a9)=42; a9[0]==a9[9] && a9[0]==42'
# rg1 = rg2
scc -a1 'range(v0) = a9; ++v0==++range(a9) && v0++ == range(a9)++'
scc -a1 'range(s) = cc9; s==str(cc9)'
scc -a1 'range(v9) = range(5); ++v9==0 && v9++==4'
# Rg || F ################################################################ FOLD
scc -a1 '(v9 || min) + (mk_v9()||min) == 0'
scc -a6 'vint{1,5} || function<int(int,int)>(std::plus<int>())'
scc -a45 'v9 || std::plus<int>()'
scc -a45 'v9 || plus_'
scc -a0 'int mn= v9 || [](int a, int b){return min(a,b);}; mn'
scc -a45 'vs9 * size || plus<int>()'
#scc -a3 'vint{1,2,3} || size'
#scc -a0 'vint{} || size'
# empty ranges
scc 'range(0) || plus_, range(3) || plus_'
scc 'range(0) || multiplies_, range(3) || multiplies_'
scc 'range(0) || minus_, range(3) || minus_'
scc 'range(0) || ro::divides_, range(1,3) || ro::divides_'
#
####################################### FUNCTORS
# stl algorithms
scc 'vint{3,1,2} | sort | reverse'
scc 'v9 | random_shuffle'
# Now applying inplace algorithm (like sort) to a lazy range is undefined behavior.
# TODO: if inplace-algo is applyed to lazy of read-only range => make copy before applying this algo
scc 'str s("HELLOW WORLD 321"); s | isalpha | sort ; s | isalpha'
# cstr
scc 'char s[99]="old old old"; range(s) = range("new"); s'
# conversions
# TOFIX scc 'set<char> s = range("aabbc"); s'