RosettaCodeData/Task/Averages-Mode/Perl-6/averages-mode-3.pl6
2016-12-05 22:15:40 +01:00

8 lines
272 B
Raku

sub mode (*@a) {=
return |(@a
.Bag # count elements
.classify(*.value) # group elements with the same count
.max(*.key) # get group with the highest count
.value.map(*.key); # get elements in the group
);
}