aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark <53903062+andemark@users.noreply.github.com>2023-10-24 22:40:00 +0000
committerMark <53903062+andemark@users.noreply.github.com>2023-10-24 22:40:00 +0000
commit5cdaa96487bf91a52a0bdfc689bb855a9d1e920c (patch)
tree890c660f2c6ecb624e9a10aa74cb6741065b376e
parentfaaf5da6ddf7066c65990dc6d78cf2a0405473c7 (diff)
downloadperlweeklychallenge-club-5cdaa96487bf91a52a0bdfc689bb855a9d1e920c.tar.gz
perlweeklychallenge-club-5cdaa96487bf91a52a0bdfc689bb855a9d1e920c.tar.bz2
perlweeklychallenge-club-5cdaa96487bf91a52a0bdfc689bb855a9d1e920c.zip
Challenge 240 Solutions (Raku)
-rw-r--r--challenge-240/mark-anderson/perl/ch-1.pl14
-rw-r--r--challenge-240/mark-anderson/perl/ch-2.pl9
-rw-r--r--challenge-240/mark-anderson/raku/ch-1.raku15
3 files changed, 14 insertions, 24 deletions
diff --git a/challenge-240/mark-anderson/perl/ch-1.pl b/challenge-240/mark-anderson/perl/ch-1.pl
deleted file mode 100644
index 9abad2e64e..0000000000
--- a/challenge-240/mark-anderson/perl/ch-1.pl
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env perl
-use List::Util qw/all zip/;
-use experimental qw/signatures/;
-use Test2::V0;
-plan 3;
-
-ok acronym([qw/Perl Python Pascal/], 'ppp');
-ok not acronym([qw/Perl Raku/], 'rp');
-ok acronym([qw/Oracle Awk C/], 'oac');
-
-sub acronym($arr, $ck)
-{
- all { uc $_->[1] eq substr $_->[0], 0, 1 } zip $arr, [split //, $ck]
-}
diff --git a/challenge-240/mark-anderson/perl/ch-2.pl b/challenge-240/mark-anderson/perl/ch-2.pl
deleted file mode 100644
index 604c5ea8ba..0000000000
--- a/challenge-240/mark-anderson/perl/ch-2.pl
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env perl
-use experimental qw/signatures/;
-use Test2::V0;
-plan 2;
-
-is build_array([0,2,1,5,3,4]), [0,1,2,4,5,3];
-is build_array([5,0,1,2,3,4]), [4,5,0,1,2,3];
-
-sub build_array($arr) { [ @$arr[@$arr] ] }
diff --git a/challenge-240/mark-anderson/raku/ch-1.raku b/challenge-240/mark-anderson/raku/ch-1.raku
index 10e7e3f8c7..bfc89678c9 100644
--- a/challenge-240/mark-anderson/raku/ch-1.raku
+++ b/challenge-240/mark-anderson/raku/ch-1.raku
@@ -5,7 +5,20 @@ ok acronym(<Perl Python Pascal>, 'ppp');
nok acronym(<Perl Raku>, 'rp');
ok acronym(<Oracle Awk C>, 'oac');
+# This solution gives a warning but I don't think it should.
+
+# Whitespace is insignificant in raku regexes but it gives a warning
+# that whitespace is insignificant?
+
+# It only does this when there is 1 whitespace character. If there
+# are 2 or more it doesn't.
+
+# For example, from docs.raku.org/language/regexes
+# say so "I used Photoshop®" ~~ m:i/ photo shop /; # OUTPUT: «True␤»
+# gives a warning but if there are 2 spaces between photo and shop then
+# there is no warning.
+
sub acronym(@a, $ck)
{
- so all map { .[0].starts-with(.[1].uc) }, (@a Z $ck.comb)
+ so $ck ~~ m:i/ <{ "@a.match(/ <|w> <:Lu> /, :g)" }> /
}