Autogram checker: Difference between revisions
m
→{{header|Raku}}: style tweaks
Thundergnat (talk | contribs) m (→{{header|Raku}}: Declutter sligthly. Better names. Filter out full stop (oops). Add a link to module and install command) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: style tweaks) |
||
Line 96:
for %nums.kv -> $word, $number { $str ~~ s:g/ <|w> $word <|w> /$number/ }
$str ~~ s:g/ (\d)<ws>['and'|'-']<ws>(\d) /$0 $1/;
$str ~~ s:g/ <|w>(\d ** 2)<ws>(\d ** 2) <|w> /{ $0
$str ~~ s:g/ ( [\d+<ws>]* \d+ ) /{[+] $0.split: ' '}/;
# Build a hash of claimed characters.
my %claim = flat $str.lc.match(:g, /\d+ <:ws> ['comma'|'apostrophe'|'hyphen'|.]/)».split(' ')»[1,0]».pairup;
for <comma , hyphen - apostrophe '> #`['] -> $
say "\nClaimed character counts:\n" ~ wrap-text :100width, %claim.sort( ~*.key ).map( { sprintf "%s\(%d)", .key, .value } ).join: ' ';
|