Help for this page

Select Code to Download


  1. or download this
    multi max (Str *@candidates) { 
        reduce {$^a gt $^b ?? $^a :: $^b} @candidates;
    ...
    multi max (Num *@candidates) { 
        reduce {$^a > $^b ?? $^a :: $^b} @candidates;
    }
    
  2. or download this
    sub max (*@args) { 
        if want~~Str { reduce {$^a gt $^b ?? $^a :: $^b} @args }
    ...
    $biggest_num = +max @values;  # Num context, so use >
    $biggest_num =  max @values;  # scalar context, default to >
    
  3. or download this
    # Let call context decide...
    multi max (*@args) { 
    ...
    $biggest_mag    =  max {abs $^a <=> abs $^b}  @values;
    $biggest_lookup =  max {%hash{$^a} cmp %hash{$^b}  @values;