MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/examples/rpp/doxygen/reduce.cpp:10–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 **/
9
10int 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}

Callers

nothing calls this directly

Calls 3

justFunction · 0.85
reduceFunction · 0.85
subscribeFunction · 0.85

Tested by

no test coverage detected