my @list = (
<Camelia 5>,
<Camelia 6>,
<Camelia 7>,
<Amelia 1>,
<Amelia 2>,
<Amelia 3>
);
my %hash = @list.classify: *.[0], as => *.[1];
say %hash;
@list.classify: *.[0], :into(my %h), :as( *.[1] );
say %h;
my @a = slurp("README.txt").words;
my %hash = @a.classify( *.Str );
for %hash.sort({-.value.elems}).hash.kv.[^20] -> $key, $value {
say $key ,"\t", $value.elems;
}
my $a = ('a' .. 'z').roll(1000000);
say .key, ' => ', .value for $a.cache.classify(*.Str).map({.key => .value.elems}).sort({-.value});
say now - INIT now;
my @lines = "test.txt".IO.lines;
.say for @lines.classify: {.split('_')[0..2].join("_")};
my @a = 1,2,6,6,6,6,9,9;
my %hash = @a.classify(*.Str);
for %hash.kv -> $k,$v {say "$k | $v.elems()"}
.say for slurp("README.md")\
.words()\
.classify( *.Str )\
.map({;.key => .value.elems })\
.sort( { -.value } )\
.[ ^10 ];
my @names = <Patrick Jonathan Larry Moritz Audrey>;
say .key, "\t", ~.values
for @names.classify( *.chars );
my @lines = "README.txt".IO.lines;
.say for @lines.classify: {.split('_')[0..2].join("_")};