Is there an elegant zip to interleave two lists in Perl 5?

后端 未结 7 676
一向
一向 2020-12-02 15:45

I recently \"needed\" a zip function in Perl 5 (while I was thinking about How do I calculate relative time?), i.e. a function that takes two lists and \"zips\" them togethe

相关标签:
7条回答
  • 2020-12-02 16:41

    For arrays of the same length:

    my @zipped = ( @a, @b )[ map { $_, $_ + @a } ( 0 .. $#a ) ];
    
    0 讨论(0)
提交回复
热议问题