Autogram checker: Difference between revisions

m
→‎{{header|Raku}}: style tweaks
m (→‎{{header|Raku}}: Declutter sligthly. Better names. Filter out full stop (oops). Add a link to module and install command)
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 *× 100 + $1}/;
$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 '> #`['] -> $aword, $bsymbol { %claim{$bsymbol} = %claim{$aword}:delete if %claim{$aword} }
say "\nClaimed character counts:\n" ~ wrap-text :100width, %claim.sort( ~*.key ).map( { sprintf "%s\(%d)", .key, .value } ).join: ' ';
 
10,333

edits