From 864b9f9491fddbccb4ca67d7da37c0a3c7f7a6bb Mon Sep 17 00:00:00 2001 From: Andrew Shitov Date: Mon, 22 Nov 2021 10:20:16 +0100 Subject: ash 140, task 2 in Raku --- challenge-140/ash/raku/ch-2.raku | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 challenge-140/ash/raku/ch-2.raku diff --git a/challenge-140/ash/raku/ch-2.raku b/challenge-140/ash/raku/ch-2.raku new file mode 100644 index 0000000000..7804aff7de --- /dev/null +++ b/challenge-140/ash/raku/ch-2.raku @@ -0,0 +1,5 @@ +# This is definitely is not efficient, but it displays the power of Raku syntax. + +sub MAIN($a, $b, $n) { + say (sort 1..$a X* 1..$b)[$n - 1] +} -- cgit From 9d594ecfc11abdb82fc6de4408faebc54e54a506 Mon Sep 17 00:00:00 2001 From: Andrew Shitov Date: Mon, 22 Nov 2021 10:20:49 +0100 Subject: typo --- challenge-140/ash/raku/ch-2.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-140/ash/raku/ch-2.raku b/challenge-140/ash/raku/ch-2.raku index 7804aff7de..948c313bb0 100644 --- a/challenge-140/ash/raku/ch-2.raku +++ b/challenge-140/ash/raku/ch-2.raku @@ -1,4 +1,4 @@ -# This is definitely is not efficient, but it displays the power of Raku syntax. +# This definitely is not efficient, but it displays the power of Raku syntax. sub MAIN($a, $b, $n) { say (sort 1..$a X* 1..$b)[$n - 1] -- cgit From 1841df52444effa0ae8f14942eb25e5daf36357c Mon Sep 17 00:00:00 2001 From: Andrew Shitov Date: Mon, 22 Nov 2021 10:27:22 +0100 Subject: ash 140, task 1 in Raku --- challenge-140/ash/raku/ch-1.raku | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 challenge-140/ash/raku/ch-1.raku diff --git a/challenge-140/ash/raku/ch-1.raku b/challenge-140/ash/raku/ch-1.raku new file mode 100644 index 0000000000..e7828a4c3e --- /dev/null +++ b/challenge-140/ash/raku/ch-1.raku @@ -0,0 +1,21 @@ +class Binary { + has Str $.value; + + method gist() returns Str { + return $.value; + } +} + +# Do not forget "multi" here as otherwise it will overload too much, including the built-in infix:<+>(Int, Int). +multi sub infix:<+>(Binary $a, Binary $b) returns Binary { + my Int $sum = "0b{$a.value}".Int + "0b{$b.value}".Int; + + return Binary.new(value => $sum.base(2)); +} + +sub MAIN(IntStr $a, IntStr $b) { + my $x = Binary.new(value => $a); + my $y = Binary.new(value => $b); + + say $x + $y; +} -- cgit