Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by oiskuu (Friar)
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 romping around the Monastery: (11)
As of 2014-12-26 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls