Front page | perl.perl5.porters |
Postings from February 2022
Re: PSC #054 2022-02-11
Thread Previous
|
Thread Next
From:
Oodler 577 via perl5-porters
Date:
February 15, 2022 23:12
Subject:
Re: PSC #054 2022-02-11
Message ID:
YgwzXinUo9iU2i8I@odin.sdf-eu.org
* Ricardo Signes <perl.p5p@rjbs.manxome.org> [2022-02-15 17:09:15 -0500]:
> 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?
Ah, thank you - the examples below are the motivation.
>
> 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.
This is nice.
>
> > 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
Excellent, thank you.
Cheers,
Brett
>
> --
> rjbs
--
--
oodler@cpan.org
oodler577@sdf-eu.org
SDF-EU Public Access UNIX System - http://sdfeu.org
irc.perl.org #openmp #pdl #native
Thread Previous
|
Thread Next