Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How can I find the index of the biggest element in an array?

by DillonYu (Novice)
on Mar 14, 2017 at 08:21 UTC ( [id://1184519]=note: print w/replies, xml ) Need Help??


in reply to How can I find the index of the biggest element in an array?

Use mod:://List::Util's reduce:
use List::Util qw /reduce/; my @arr= qw/7 6 4 90 5 7/; my $index = reduce {$arr[$a] > $arr[$b] ? $a : $b} (0 .. $#arr); print "$index\n";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-19 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found