develooper Front page | perl.perl5.porters | Postings from July 2021

Re: Elevator pitch, deprecating $a/$b sort globals by using sub{}

Thread Previous | Thread Next
From:
Oodler 577 via perl5-porters
Date:
July 5, 2021 20:59
Subject:
Re: Elevator pitch, deprecating $a/$b sort globals by using sub{}
Message ID:
20210705205859.GG26930@odin.sdf-eu.org
* Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> [2021-07-05 20:29:49 +0100]:

> On Sun, 4 Jul 2021 17:02:00 +0000
> Nicholas Clark <nick@ccl4.org> wrote:
> 
> > Our problem here is that sort needs two implicit arguments. *Is* it
> > the only operator that wants >1 implicit argument?
> 
> `reduce`
> 
> as in eg.
> 
>   my $item = reduce { $a->{$b} } $href, @innerkeys;

What is the meaning of this? I get the words you wrote, but I don't
understand what you're implying by the hypothetical code example.
That looks a lot more like a 2-arg C<map>, not a "reduce".

Do you mean something more like,

  my $max = reduce { $a >= $b } @values; # not claiming semantic correctness

  my $max = reduce { $a > $b } @values;  # perhaps a 'stable' version 

As far as I know a "reduce" results in a single value from many -
or fewer than the original number...not to lead this off the rails,
I just don't undertand the point of 'reduce' above.

Brett

> 
> -- 
> Paul "LeoNerd" Evans
> 
> leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
> http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

-- 
--
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


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