Help for this page

Select Code to Download


  1. or download this
    use List::Util qw( reduce );
    
    ...
       my ($ar) = @_;
       return reduce { $ar->[$b] > $ar->[$a] ? $b : $a } 0..$#$ar;
    }
    
  2. or download this
    sub min_idx {
       my ($ar) = @_;
    ...
       for (1..$#$ar) { $idx = $_ if $arr->[$_] > $arr->[$idx]; }
       return $idx;
    }
    
  3. or download this
    my $min_idx = min_index(\@a);