C++ Streams has iterate() which takes an initial value, n and a function, f() then produces first n followed by f(n), f(f(n))...
auto stream = MakeStream::iterate(1245, [](int x) {
if(x % 2 == 0) {
return x / 2;
} else {
return 3 * x + 1;
}
});
What does Range V3 have for this?
In range-v3 you would create such a range with
view::generate:DEMO