Skip to content

Commit

Permalink
Merge pull request #3269 from Raku/any-minmax-by
Browse files Browse the repository at this point in the history
Explicitly mention min/max/minmax()'s :by argument
  • Loading branch information
JJ committed Mar 21, 2020
2 parents 11af520 + f3af1a0 commit c9317ce
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doc/Type/Any.pod6
Expand Up @@ -567,12 +567,15 @@ Defined as:
Coerces the invocant to L<Iterable|/type/Iterable> and returns the numerically
smallest element; in the case of C<Hash>es, it returns the C<Pair> with the
lowest value. In C<sub> form, the invocant is passed as an argument.
lowest value.
If a L<Callable|/type/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 C<min>.
In C<sub> form, the invocant is passed as an argument and a comparison C<Callable>
can be specified with the named argument C<:by>.
say (1,7,3).min(); # OUTPUT:«1␤»
say (1,7,3).min({1/$_}); # OUTPUT:«7␤»
say min(1,7,3); # OUTPUT: «1␤»
Expand All @@ -596,6 +599,9 @@ If a L<Callable|/type/Callable> positional argument is provided, each value is
passed into the filter, and the return value is compared instead of the original
value. The original value is still the one returned from C<max>.
In C<sub> form, the invocant is passed as an argument and a comparison C<Callable>
can be specified with the named argument C<:by>.
say (1,7,3).max(); # OUTPUT:«7␤»
say (1,7,3).max({1/$_}); # OUTPUT:«1␤»
say max(1,7,3,:by( { 1/$_ } )); # OUTPUT: «1␤»
Expand All @@ -617,6 +623,9 @@ If a L<Callable|/type/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 values are still used in the returned C<Range>.
In C<sub> form, the invocant is passed as an argument and a comparison C<Callable>
can be specified with the named argument C<:by>.
say (1,7,3).minmax(); # OUTPUT:«1..7␤»
say (1,7,3).minmax({-$_}); # OUTPUT:«7..1␤»
say minmax(1,7,3); # OUTPUT: «1..7␤»
Expand Down

0 comments on commit c9317ce

Please sign in to comment.