See Original text in context
method min(Supply: = :<cmp> --> Supply)
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.
See Original text in context
method min(Range:)
Returns the start point of the range.
say (1..5).min; # OUTPUT: «1»say (1^..^5).min; # OUTPUT: «1»
See Original text in context
multi method min()multi method min()multi sub min(+args, :!)multi sub min(+args)
Coerces the invocant to Iterable and returns the numerically smallest element; in the case of Hash
es, it returns the Pair
with the lowest value.
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
.
In sub
form, the invocant is passed as an argument and a comparison Callable
can be specified with the named argument :by
.
say (1,7,3).min(); # OUTPUT:«1»say (1,7,3).min(); # OUTPUT:«7»say min(1,7,3); # OUTPUT: «1»say min(1,7,3,:by( )); # OUTPUT: «7»min( %(a => 3, b=> 7 ) ).say ; # OUTPUT: «a => 3»
See Original text in context
Returns the smallest of the arguments, as determined by cmp semantics.
my = 42;min= 0 # read as: $foo decreases to 0
Note: Before 2022.06, in the cases of ties &min
would return the first argument with that value, whereas &[min]
would return its RHS. After 2022.06, &[min]
returns its LHS in the case of ties, and now both return the same value as dictated by their List associativity.
say min 0, False; # OUTPUT: «0»say 0 min False; # OUTPUT: «0»say min False, 0; # OUTPUT: «False»say False min 0; # OUTPUT: «False»