diff options
| author | Aleks-Daniel Jakimenko-Aleksejev <alex.jakimenko@gmail.com> | 2019-04-07 22:00:55 +0300 |
|---|---|---|
| committer | Aleks-Daniel Jakimenko-Aleksejev <alex.jakimenko@gmail.com> | 2019-04-07 22:00:55 +0300 |
| commit | 033c392bcf37b969203ec5de979715a29e55e4a9 (patch) | |
| tree | 4bd3bf475eb96ace348a9eb5f2fecd8406e490b0 | |
| parent | 8f7719c0ac474fe834ed9b30a3ef61edc73892aa (diff) | |
| download | perlweeklychallenge-club-033c392bcf37b969203ec5de979715a29e55e4a9.tar.gz perlweeklychallenge-club-033c392bcf37b969203ec5de979715a29e55e4a9.tar.bz2 perlweeklychallenge-club-033c392bcf37b969203ec5de979715a29e55e4a9.zip | |
My solutions for week 2
| -rw-r--r-- | challenge-002/alexdaniel/perl6/ch-1.p6 | 9 | ||||
| -rw-r--r-- | challenge-002/alexdaniel/perl6/ch-2.p6 | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/challenge-002/alexdaniel/perl6/ch-1.p6 b/challenge-002/alexdaniel/perl6/ch-1.p6 new file mode 100644 index 0000000000..a98b84fe71 --- /dev/null +++ b/challenge-002/alexdaniel/perl6/ch-1.p6 @@ -0,0 +1,9 @@ +# Supports any unicode digits, so ႐႐၄၂ will be trimmed to ၄၂. +# Zero and positive numbers are not trimmed because the task +# specifically asks for positive numbers. However, it is not specified +# what a “number” is, and same goes for formatting requirements (e.g. +# “.5“ vs “0.5”), therefore I decided to keep it simple and just do +# the integers. So it's just a neat example on how to do unicode-aware +# number matching. + +put S:r/^[ <:Nd> & <:Numeric_Value(0)> ]* <before <:Nd>+$>// for lines diff --git a/challenge-002/alexdaniel/perl6/ch-2.p6 b/challenge-002/alexdaniel/perl6/ch-2.p6 new file mode 100644 index 0000000000..ade157486b --- /dev/null +++ b/challenge-002/alexdaniel/perl6/ch-2.p6 @@ -0,0 +1,9 @@ +#| From base 10 to base 35 +sub postfix:<₃₅>(Real() $a) { $a.base: 35 } +#| From base 35 to base 10 +sub postfix:<₁₀>( Str() $a) { $a.parse-base: 35 } + +say ‘ALEXDANIEL’₁₀; +say 836407881643061₃₅; + +# You can do non-ints too, but they won't roundtrip as you might expect |
