Два мира...
Sep. 19th, 2022 10:44 pmPython
Сами-знаете-что версии 20
Сколько синтаксиса, мммм!
names = ['foo', 'bar', 'baz', 'qux'] for i, v in zip(range(100000), names): prinf(i,v)
Сами-знаете-что версии 20
#include <cstdlib>
#include <vector>
#include <string>
#include <string_view>
#include <ranges>
#include <iostream>
using namespace std;
using namespace std::literals;
int main() {
vector<string_view> names{"foo"sv, "bar"sv, "baz"sv, "qux"sv};
auto index = [i = std::size_t{0}]<typename T>(const T&ref) mutable {
return std::pair{i++, ref};
};
for(auto const &[i,n] : names | ranges::views::transform(index) ) {
cout << i << " " << n << endl;
}
return EXIT_SUCCESS;
}
Сколько синтаксиса, мммм!