PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.28.0
Code Block Pro – Beautiful Syntax Highlighting v1.28.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / raku.sample

raku.sample in Code Block Pro – Beautiful Syntax Highlighting 1.28.0, at build/shiki/samples/raku.sample

38 lines 899 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 use v6;
2
3 # start by printing out the header.
4 say "Tournament Results:\n";
5
6 my $file = open 'scores.txt'; # get filehandle and...
7 my @names = $file.get.words; # ... get players.
8
9 my %matches;
10 my %sets;
11
12 for $file.lines -> $line {
13 next unless $line; # ignore any empty lines
14
15 my ($pairing, $result) = $line.split(' | ');
16 my ($p1, $p2) = $pairing.words;
17 my ($r1, $r2) = $result.split(':');
18
19 %sets{$p1} += $r1;
20 %sets{$p2} += $r2;
21
22 if $r1 > $r2 {
23 %matches{$p1}++;
24 } else {
25 %matches{$p2}++;
26 }
27 }
28
29 my @sorted = @names.sort({ %sets{$_} }).sort({ %matches{$_} }).reverse;
30
31 for @sorted -> $n {
32 my $match-noun = %matches{$n} == 1 ?? 'match' !! 'matches';
33 my $set-noun = %sets{$n} == 1 ?? 'set' !! 'sets';
34 say "$n has won %matches{$n} $match-noun and %sets{$n} $set-noun";
35 }
36
37 # From https://docs.raku.org/language/101-basics
38