From a3d7d532eab68e3edde77df48b701485ef6f38ad Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Thu, 8 Oct 2020 15:11:46 +0200 Subject: bugfix and optimization --- challenge-081/markus-holzer/raku/ch-1.raku | 14 +++++++++----- challenge-081/markus-holzer/raku/ch-2.raku | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/challenge-081/markus-holzer/raku/ch-1.raku b/challenge-081/markus-holzer/raku/ch-1.raku index ee685600da..f3b9e8c8e6 100644 --- a/challenge-081/markus-holzer/raku/ch-1.raku +++ b/challenge-081/markus-holzer/raku/ch-1.raku @@ -1,10 +1,14 @@ unit sub MAIN( Str, Str ); -my Str $A = @*ARGS.min; -my Str $B = @*ARGS.max; +my Str $A = @*ARGS.min(*.chars); +my Str $B = @*ARGS.max(*.chars); # Custom operator, just for fun -multi sub infix:<%%>( Str $n, Str $d ) { - $n eq $d x $n.chars div $d.chars } +multi sub infix:<%%>( Str $n, Str $d ) returns Bool { + #will always be a Rat + given $n.chars / $d.chars { + .denominator == 1 + ?? $n eq $d x $_ + !! False }} -.say for grep $B %% *, [\~] $A.comb \ No newline at end of file +.say for grep all($A, $B) %% *, [\~] $A.comb \ No newline at end of file diff --git a/challenge-081/markus-holzer/raku/ch-2.raku b/challenge-081/markus-holzer/raku/ch-2.raku index 7f6ab7aadc..c9d0bad20c 100644 --- a/challenge-081/markus-holzer/raku/ch-2.raku +++ b/challenge-081/markus-holzer/raku/ch-2.raku @@ -11,4 +11,4 @@ my $words = $file .classify( *.value ); say "{$_} : {sort $words{$_}>>.key}" - for sort $words.keys; \ No newline at end of file + for sort keys $words; \ No newline at end of file -- cgit From 1cdbe1caf321faa72362f4a6c2c8ba5ec0c36ba0 Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Thu, 8 Oct 2020 15:17:22 +0200 Subject: bugfix and optimization --- challenge-081/markus-holzer/raku/ch-1.raku | 1 - 1 file changed, 1 deletion(-) diff --git a/challenge-081/markus-holzer/raku/ch-1.raku b/challenge-081/markus-holzer/raku/ch-1.raku index f3b9e8c8e6..db9c216af9 100644 --- a/challenge-081/markus-holzer/raku/ch-1.raku +++ b/challenge-081/markus-holzer/raku/ch-1.raku @@ -5,7 +5,6 @@ my Str $B = @*ARGS.max(*.chars); # Custom operator, just for fun multi sub infix:<%%>( Str $n, Str $d ) returns Bool { - #will always be a Rat given $n.chars / $d.chars { .denominator == 1 ?? $n eq $d x $_ -- cgit From 9817474c0b7f76d936b16a38a836c13bf6d69ab3 Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Thu, 8 Oct 2020 15:38:00 +0200 Subject: bugfix and optimization --- challenge-081/markus-holzer/raku/ch-1.raku | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/challenge-081/markus-holzer/raku/ch-1.raku b/challenge-081/markus-holzer/raku/ch-1.raku index db9c216af9..d29156c0bb 100644 --- a/challenge-081/markus-holzer/raku/ch-1.raku +++ b/challenge-081/markus-holzer/raku/ch-1.raku @@ -6,8 +6,6 @@ my Str $B = @*ARGS.max(*.chars); # Custom operator, just for fun multi sub infix:<%%>( Str $n, Str $d ) returns Bool { given $n.chars / $d.chars { - .denominator == 1 - ?? $n eq $d x $_ - !! False }} + .denominator == 1 && $n eq $d x $_ }} -.say for grep all($A, $B) %% *, [\~] $A.comb \ No newline at end of file +.say for grep all($A, $B) %% *, [\~] $A.comb; -- cgit From 94fb7bfc97525637029b22a4727db362edde6374 Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Thu, 8 Oct 2020 15:40:30 +0200 Subject: avoid $_ --- challenge-081/markus-holzer/raku/ch-1.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-081/markus-holzer/raku/ch-1.raku b/challenge-081/markus-holzer/raku/ch-1.raku index d29156c0bb..e9a18dd53e 100644 --- a/challenge-081/markus-holzer/raku/ch-1.raku +++ b/challenge-081/markus-holzer/raku/ch-1.raku @@ -6,6 +6,6 @@ my Str $B = @*ARGS.max(*.chars); # Custom operator, just for fun multi sub infix:<%%>( Str $n, Str $d ) returns Bool { given $n.chars / $d.chars { - .denominator == 1 && $n eq $d x $_ }} + .denominator == 1 && $n eq $d x .numerator }} .say for grep all($A, $B) %% *, [\~] $A.comb; -- cgit