Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by oiskuu (Hermit)
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 scrutinizing the Monastery: (11)
As of 2016-06-28 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (359 votes). Check out past polls.