-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
71 lines (45 loc) · 1.04 KB
/
main.cpp
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
#include "include/array.hpp"
#include <iostream>
#include <string>
using namespace stdlib;
using std::cout;
using std::endl;
int main() {
array<int> a;
a.push(1);
a.push(2);
cout << "a: " << a << endl;
a.for_each([](auto x, auto i) {
cout << "a: " << i << " - " << x << endl;
});
array<int> b;
b.push(12);
b.push(3);
cout << "b: " << b << endl;
auto c = a + b;
cout << "c (a + b): " << c << endl;
a += c;
cout << "a (a + c): " << a << endl;
cout << "b * 3: " << b * 3 << endl;
a.unshift(100);
cout << "a: " << a << endl;
a.unshift(200);
cout << "a: " << a << endl;
a[0] = 1;
cout << "a: " << a << endl;
cout << a.reduce([](auto accumulator, auto current) {
return accumulator + current;
},
0) << endl;
cout << a.map([](auto value) {
return value * 2;
}) << endl;
array<int> d;
d = { 1, 2, 3, 4 };
cout << d << endl;
cout << d.slice(1, 3) << endl;
cout << d.slice(-1) << endl;
array<std::string> g = { "Hello", "1", "3", "5" };
cout << g << endl;
return 0;
}