Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Max value

by tybalt89 (Monsignor)
on Apr 16, 2019 at 17:32 UTC ( [id://1232678]=note: print w/replies, xml ) Need Help??


in reply to Re: Max value
in thread Max value

#!/usr/bin/perl # https://perlmonks.org/?node_id=1232659 use strict; use warnings; use List::Util qw( reduce ); my %hashName = (a => 1, b => 3, c => 3); sub allmax { reduce { $a->[-1] > $b->[-1] ? $a : $a->[-1] < $b->[-1] ? $b : [ @{$a}[0..@$a-2], @$b ] } @_; } my $maxref = allmax( map [ $_, $hashName{$_} ], sort keys %hashName ); print "@$maxref\n";

Outputs:

b c 3

Replies are listed 'Best First'.
Re^3: Max value
by AnomalousMonk (Archbishop) on Apr 16, 2019 at 21:02 UTC

    [-@$a..-2] would have been slightly more obscure IMHO ;-)


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232678]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found