Category : applicative

Let’s say that given a range like this std::vector<int> v{1, 4, 7, 2}; I want to generate another range where all even number are repeated a number of times equal to their value, whereas all odd numbers are left unchanged. A possible solution is the following: #include <iostream> #include <range/v3/view/join.hpp> #include <range/v3/view/transform.hpp> #include <range/v3/view/repeat_n.hpp> #include ..

Read more