routine min

Documentation for routine min assembled from the following types:

language documentation Operators

From Operators

(Operators) infix min

Returns the smallest of the arguments, as determined by cmp semantics.

my $foo = 42;
$foo min= 0   # read as: $foo decreases to 0

class Supply

From Supply

(Supply) method min

method min(Supply:D: &custom-routine-to-use = &infix:<cmp> --> Supply:D)

Creates a supply that only emits values from the given supply if they are smaller than any value seen before. In other words, from a continuously descending supply it will emit all the values. From a continuously ascending supply it will only emit the first value. The optional parameter specifies the comparator, just as with Any.min.

class Range

From Range

(Range) method min

method min(Range:D:)

Returns the start point of the range.

say (1..5).min;                                   # OUTPUT: «1␤» 
say (1^..^5).min;                                 # OUTPUT: «1␤»

class Any

From Any

(Any) method min

Defined as:

multi method min()
multi method min(&by)
multi sub min(+args:&by!)
multi sub min(+args)

Coerces the invocant to Iterable and returns the numerically smallest element; in the case of Hashes, it returns the Pair with the lowest value. In sub form, the invocant is passed as an argument.

If a Callable positional argument is provided, each value is passed into the filter, and its return value is compared instead of the original value. The original value is still the one returned from min.

say (1,7,3).min();              # OUTPUT:«1␤» 
say (1,7,3).min({1/$_});        # OUTPUT:«7␤» 
say min(1,7,3);                 # OUTPUT: «1␤» 
say min(1,7,3,:by{ 1/$_ } )); # OUTPUT: «7␤» 
min( %(=> 3b=> 7 ) ).say ;  # OUTPUT: «a => 3␤»