-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerator-1.cc
More file actions
37 lines (32 loc) · 873 Bytes
/
generator-1.cc
File metadata and controls
37 lines (32 loc) · 873 Bytes
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
#include "eventuals/compose.h"
#include "eventuals/generator.h"
#include "eventuals/iterate.h"
#include "eventuals/map.h"
#include "eventuals/promisify.h"
#include "eventuals/reduce.h"
#include "eventuals/then.h"
using namespace eventuals;
Generator::Of<std::string> SomeFunction() {
return []() {
return Iterate({"hello", " ", "world", "!"})
>> Map([](std::string&& s) {
s[0] = std::toupper(s[0]);
return std::move(s);
});
};
}
int main(int argc, char** argv) {
auto e = []() {
return SomeFunction()
>> Reduce(
/* result = */ std::string(),
[](auto& result) {
return Then([&](auto&& value) {
result += value;
return true;
});
});
};
CHECK_EQ("Hello World!", *e());
return 0;
}