Help for this page

Select Code to Download


  1. or download this
    use List::Util 'max';
    my $largest_val = max map { expensive_func($_) } @items;
    
  2. or download this
    my $largest_item = argmax { expensive_func($_) } @items;
    
  3. or download this
    my ($largest_item, $largest_val) = argmax { expensive_func($_) } @item
    +s;
    
  4. or download this
    sub argmax(&@) {
        my $index = undef;
    ...
        }
        return wantarray ? ($index, $min) : $index;
    }