Anonymous user
Averages/Mode: Difference between revisions
→{{header|Perl 6}}: update code to be idiomatic rather than literally translated Perl 5, and use object identity instead of string comparison
(→{{header|Perl 6}}: update code to be idiomatic rather than literally translated Perl 5, and use object identity instead of string comparison) |
|||
Line 1,945:
=={{header|Perl 6}}==
{{works with|Rakudo|
<lang perl6>sub mode (*@a) {
my %counts := @a.Bag;
my $max = %counts.values.max;
}</lang>
Testing with arrays:
<lang perl6>say mode [1, 3, 6, 6, 6, 6, 7, 7, 12, 12, 17];
say mode [1, 1, 2, 4, 4];</lang>
{{out}}
<pre>
6
(4 1)
</pre>
=={{header|Phix}}==
|