Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^7: index of the minimum element of the array

by oiskuu (Pilgrim)
on Jan 17, 2014 at 19:41 UTC ( #1071011=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      sub foo { map { print $_[$_] } 0 .. $#_ }
    
  2. or download this
    use List::Util 'reduce';
    sub minindex { reduce { $_[$a] < $_[$b] ? $a : $b } 0 .. $#_ }
    ...
    my @g = (55, 88, 33, 6, 234, 234, 52, 6, 1324, 22, 1234);
    
    print minindex @g;              # $g[7] == 6
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-09-01 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (299 votes), past polls