@@ -884,7 +884,9 @@ Can take a separator, which is an empty string by default.
884
884
multi sub categorize($test, +items, :$into!, *%named )
885
885
multi sub categorize($test, +items, *%named )
886
886
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.
888
890
889
891
In its simplest form, it uses a C < $test > whose result will be used as a key; the
890
892
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 );
934
936
In this case, every number in the range is classified in as many bins as it can
935
937
be divided by.
936
938
939
+ Support for using C < Whatever > as the test was added in Rakudo compiler
940
+ version 2023.02.
941
+
937
942
= head2 routine classify
938
943
939
944
multi method classify()
@@ -943,10 +948,14 @@ be divided by.
943
948
multi sub classify($test, +items, :$into!, *%named )
944
949
multi sub classify($test, +items, *%named )
945
950
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.
950
959
951
960
= for code
952
961
my @years = (2003..2008).map( { Date.new( $_~"-01-01" ) } );
@@ -963,6 +972,9 @@ into; in the example above, it's defined on the fly.
963
972
964
973
From version 6.d, C < .classify > will also work with C < Junctions > .
965
974
975
+ Support for using C < Whatever > as the test was added in Rakudo compiler
976
+ version 2023.02.
977
+
966
978
= head2 routine reduce
967
979
968
980
multi method reduce(Any:U: & --> Nil)
0 commit comments