develooper Front page | perl.perl5.porters | Postings from February 2022

Re: PSC #054 2022-02-11

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
February 15, 2022 22:09
Subject:
Re: PSC #054 2022-02-11
Message ID:
2afcc294-9231-4342-ac99-fc2138361d6d@beta.fastmail.com
On Tue, Feb 15, 2022, at 12:57 PM, Oodler 577 wrote:
> E.g., I mistakenly thought that:
> 
> 1. for %hashes, it'd iterate pairwise returning the
> actual ($key, $value)
> 
> 2. for @arrays, it'd do the same - provide every 2
> elements of the array;

I don't understand why this would be useful.  Could you explain?

The *general* motivator for this feature has been to allow key-and-value pair iteration.  For hashes, that's:
for my ($k, $v) (%hash) {
  ...
}

For by-twos iteration of an array, that's:
for my ($even, $odd) (@array) {
  ...
}

The time you'd want to add some new value is when you want the indexes of the array.

> If this is attractive (I'm personally excited about it), I'd be happy to write up a pre-RFC for it.

zip is already present in the core distribution as part of List::Util v1.56 which will see its first inclusion with a non-dev perl in v5.36.0

-- 
rjbs
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About