| 8 | **/ |
| 9 | |
| 10 | int main() |
| 11 | { |
| 12 | //! [reduce] |
| 13 | rpp::source::just(1, 2, 3) |
| 14 | | rpp::operators::reduce(std::string{}, [](std::string&& seed, int v) { return std::move(seed) + std::to_string(v) + ","; }) |
| 15 | | rpp::operators::subscribe([](const std::string& v) { std::cout << v << std::endl; }); |
| 16 | // Output: 1,2,3, |
| 17 | //! [reduce] |
| 18 | |
| 19 | //! [reduce_no_seed] |
| 20 | rpp::source::just(1, 2, 3) |
| 21 | | rpp::operators::reduce(std::plus<int>{}) |
| 22 | | rpp::operators::subscribe([](int v) { std::cout << v << std::endl; }); |
| 23 | // Output: 6 |
| 24 | //! [reduce_no_seed] |
| 25 | return 0; |
| 26 | } |