Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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?
[robby_dobby]: I attended a couple conferences (both in India). Left me with a renewed enthusiasm to do more, only to see it disappear in a few days!
[LanX]: Then come to YAPC EU in Amsterdam ...
[robby_dobby]: LanX: But that's in Africa! More like YAPC::Africa
choroba fears Amsterdam might fill him with enthusiasm to do nothing
[robby_dobby]: Uff, too expensive :-(
[LanX]: ... I found YAPC EU more entertaining (and international )than YAPC NA
[robby_dobby]: What's the site for YAPC::EU?
[LanX]: Robby Dobby no IIRC Sinai is already part of Asia
[robby_dobby]: blogs.perl.org page for yapceu is out of date by 2 years
[robby_dobby]: LanX: Sharm-el-Sheikh is in Egypt

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-04-24 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.