Skip to content

Commit 63083c6

Browse files
committed
Document Any.classify|categorize(*)
1 parent 0d25f95 commit 63083c6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

doc/Type/Any.pod6

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,9 @@ Can take a separator, which is an empty string by default.
884884
multi sub categorize($test, +items, :$into!, *%named )
885885
multi sub categorize($test, +items, *%named )
886886
887-
The two first forms fail with an error message.
887+
The first form will always fail. The second form classifies on the
888+
identity of the given object, which usually only makes sense in
889+
combination with the C<:&as> argument.
888890
889891
In its simplest form, it uses a C<$test> whose result will be used as a key; the
890892
values of the key will be an array of the elements that produced that key as a
@@ -934,6 +936,9 @@ say (3..13).categorize( &divisible-by );
934936
In this case, every number in the range is classified in as many bins as it can
935937
be divided by.
936938
939+
Support for using C<Whatever> as the test was added in Rakudo compiler
940+
version 2023.02.
941+
937942
=head2 routine classify
938943
939944
multi method classify()
@@ -943,10 +948,14 @@ be divided by.
943948
multi sub classify($test, +items, :$into!, *%named )
944949
multi sub classify($test, +items, *%named )
945950
946-
The two first forms will fail. The rest include a C<$test>, which is a function
947-
that will return a scalar for every input; these will be used as keys of a hash
948-
whose values will be arrays with the elements that output that key for the test
949-
function.
951+
The first form will always fail. The second form classifies on the
952+
identity of the given object, which usually only makes sense in
953+
combination with the C<:&as> argument.
954+
955+
The rest include a C<$test> argument, which is a function that will
956+
return a scalar for every input; these will be used as keys of a hash
957+
whose values will be arrays with the elements that output that key for
958+
the test function.
950959
951960
=for code
952961
my @years = (2003..2008).map( { Date.new( $_~"-01-01" ) } );
@@ -963,6 +972,9 @@ into; in the example above, it's defined on the fly.
963972
964973
From version 6.d, C<.classify> will also work with C<Junctions>.
965974
975+
Support for using C<Whatever> as the test was added in Rakudo compiler
976+
version 2023.02.
977+
966978
=head2 routine reduce
967979
968980
multi method reduce(Any:U: & --> Nil)

0 commit comments

Comments
 (0)