[personal profile] ex0_planet
Python
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;
}


Сколько синтаксиса, мммм!

Date: 2022-09-20 12:49 pm (UTC)
From: [personal profile] max_tx
Там в питоновском коде print(i,v) должно быть)))

Profile

ex0_planet

April 2023

S M T W T F S
      1
234567 8
910111213 1415
16171819202122
23242526272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 24th, 2026 08:19 am
Powered by Dreamwidth Studios