diff options
| author | Humberto Massa <humbertomassa@gmail.com> | 2023-11-09 06:35:35 -0300 |
|---|---|---|
| committer | Humberto Massa <humbertomassa@gmail.com> | 2023-11-09 06:35:35 -0300 |
| commit | c7cd3e2ea5883404c6ae18ef6621a075e24210d4 (patch) | |
| tree | 57e3ff808ea10af9c3659b693dfa46a2e8fae6fa | |
| parent | 9518d58f43543361c49af92b9d919d8b8c4c10f0 (diff) | |
| download | perlweeklychallenge-club-c7cd3e2ea5883404c6ae18ef6621a075e24210d4.tar.gz perlweeklychallenge-club-c7cd3e2ea5883404c6ae18ef6621a075e24210d4.tar.bz2 perlweeklychallenge-club-c7cd3e2ea5883404c6ae18ef6621a075e24210d4.zip | |
unifying test syntax
| -rw-r--r-- | challenge-242/massa/raku/ch-1.raku | 18 | ||||
| -rw-r--r-- | challenge-242/massa/raku/ch-2.raku | 21 |
2 files changed, 18 insertions, 21 deletions
diff --git a/challenge-242/massa/raku/ch-1.raku b/challenge-242/massa/raku/ch-1.raku index 7691ced71b..6f66804868 100644 --- a/challenge-242/massa/raku/ch-1.raku +++ b/challenge-242/massa/raku/ch-1.raku @@ -44,21 +44,21 @@ Write a script to find out the missing members in each other arrays. # always use the latest version of Raku use v6.*; -sub SOLUTION(@a, @b) { - keys(@a ∖ @b).sort.Array, keys(@b ∖ @a).sort.Array +sub SOLUTION(@ (@a, @b)) { + (@a ∖ @b, @b ∖ @a)».keys».sort } multi MAIN (Bool :$test!) { use Test; - my @tests = [ - %{ input => ([1, 2, 3], [2, 4, 6]), output => ([1, 3], [4, 6]) }, - %{ input => ([1, 2, 3, 3], [1, 1, 2, 2]), output => ([3], []) }, - ]; + my @tests = + %{ input => ((1, 2, 3), (2, 4, 6)), + output => ((1, 3), (4, 6)) }, + %{ input => ((1, 2, 3, 3), (1, 1, 2, 2)), + output => ((3,), ()) }, + ; - for @tests { - SOLUTION( |.<input> ).&is-deeply: .<output>, .<text>; - } # end of for @tests + .<input>.&SOLUTION.gist.&is: .<output>.gist, .<text> for @tests } # end of multi MAIN (Bool :$test!) diff --git a/challenge-242/massa/raku/ch-2.raku b/challenge-242/massa/raku/ch-2.raku index 58801dd5e4..bb3033c7a2 100644 --- a/challenge-242/massa/raku/ch-2.raku +++ b/challenge-242/massa/raku/ch-2.raku @@ -53,23 +53,20 @@ Write a script to flip the given matrix as below. use v6.*; sub SOLUTION(@_) { - @_».reverse».map({ $_ ?? 0 !! 1 })».Array + @_».reverse».map: 1 - * } multi MAIN (Bool :$test!) { use Test; - my @tests = [ - %{ input => ([1, 1, 0], [1, 0, 1], [0, 0, 0]), - output => ([1, 0, 0], [0, 1, 0], [1, 1, 1]) }, - %{ input => ([1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 1], [1, 0, 1, 0]), - output => ([1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1], [1, 0, 1, 0]) }, - ]; + my @tests = + %{ input => ((1, 1, 0), (1, 0, 1), (0, 0, 0)), + output => ((1, 0, 0), (0, 1, 0), (1, 1, 1)) }, + %{ input => ((1, 1, 0, 0), (1, 0, 0, 1), (0, 1, 1, 1), (1, 0, 1, 0)), + output => ((1, 1, 0, 0), (0, 1, 1, 0), (0, 0, 0, 1), (1, 0, 1, 0)) }, + ; - for @tests { - SOLUTION( .<input> ).&is-deeply: .<output>, .<text>; - - } # end of for @tests -} # end of multi MAIN (:$test!) + .<input>.&SOLUTION.gist.&is: .<output>.gist, .<text> for @tests +} # end of multi MAIN (Bool :$test!) |
