A simple case of over engineering

x = range(6)
for n in x:
print(n)
for(auto x : range(10))
{
qDebug(x);

}
generator<int> generatorForNumbers(int begin, int inc = 1) {

for (int i = begin;; i += inc) {
co_yield i;
}

}
//Put this code somewhere else...
QList<int> range(int max)
{
QList<int> list;
for(int i; i < max; i++)
{
list.append(i);
}return list;}//In the function we wanted to do this inforeach(int x, range(10))
{
}
#include <vector>
#include <numeric> //std::iota

std::vector<int> x(10);
std::iota(std::begin(x), std::end(x), 0); //0 is the starting number
std::vector<int> x;
boost::push_back(x, boost::irange(0, 10));
for(int i; i < 10; i++)
{
}
Why are you looking here, I just said don't over-engineer it!

Awarded Content Creator in the 2020 Qt Champion Awards:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store