Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by oiskuu (Hermit)
on Jan 17, 2014 at 19:41 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1071011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found