Skip to content

Instantly share code, notes, and snippets.

@RayMPerry
Created May 23, 2020 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RayMPerry/cf0d91b0858902a09673bd9f193a2db4 to your computer and use it in GitHub Desktop.
Save RayMPerry/cf0d91b0858902a09673bd9f193a2db4 to your computer and use it in GitHub Desktop.
Chinese Numerals
use v6;
sub MAIN($number = 14282) {
my $numerals = <零 一 二 三 四 五 六 七 八 九>;
my $places = $number.polymod(10, 10, 10, 10).reverse;
my Str $numbers = join "", do for ^5 -> $index {
my Int $number = $places[$index];
next if $number == 0;
$numerals[$number] ~ <万 千 百 十>[$index];
}
$numbers.say;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment