aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-06-03 01:01:46 +0200
committerMarkus "Holli" Holzer <holli.holzer@gmail.com>2020-06-03 01:01:46 +0200
commitec8f028287cbc4b32752c85abe16e359d009144a (patch)
tree10115cefeb826e4459d65fcb158bd1937ad54949
parent63c5c89eea1bf157760f2af02a3faac27fc97424 (diff)
downloadperlweeklychallenge-club-ec8f028287cbc4b32752c85abe16e359d009144a.tar.gz
perlweeklychallenge-club-ec8f028287cbc4b32752c85abe16e359d009144a.tar.bz2
perlweeklychallenge-club-ec8f028287cbc4b32752c85abe16e359d009144a.zip
a bit nicer
-rw-r--r--challenge-063/markus-holzer/ch-1.raku10
-rw-r--r--challenge-063/markus-holzer/ch-2.raku18
2 files changed, 14 insertions, 14 deletions
diff --git a/challenge-063/markus-holzer/ch-1.raku b/challenge-063/markus-holzer/ch-1.raku
index d4eedaf53e..7336e63f9c 100644
--- a/challenge-063/markus-holzer/ch-1.raku
+++ b/challenge-063/markus-holzer/ch-1.raku
@@ -1,8 +1,8 @@
-sub last-word($string, $regexp)
+sub last-word( Str $sentence, Regex $matcher )
{
- $string.words.grep( $regexp ).tail;
+ $sentence.words.grep( $matcher ).tail;
}
-say last-word(' hello world', rx/ <[ea]> l /); # 'hello'
-say last-word("Don't match too much, Chet!", rx:i/ ch . t /); # 'Chet!'
-say last-word("spaces in regexp won't match", rx/ \s re /); # undef
+say last-word( ' hello world', rx/ <[ea]> l / ); # 'hello'
+say last-word( "Don't match too much, Chet!", rx:i/ ch . t / ); # 'Chet!'
+say last-word( "spaces in regexp won't match", rx/ \s re / ); # undef
diff --git a/challenge-063/markus-holzer/ch-2.raku b/challenge-063/markus-holzer/ch-2.raku
index 2bc8aff3fe..a61e77052f 100644
--- a/challenge-063/markus-holzer/ch-2.raku
+++ b/challenge-063/markus-holzer/ch-2.raku
@@ -1,19 +1,19 @@
-say r('xyxx');
-
-multi sub r( Str $orig )
+multi sub rotmodN( Str $orig )
{
- r $orig.comb.List
+ rotmodN $orig.comb.List
}
-multi sub r( List $orig )
+multi sub rotmodN ( List $orig, $n = $orig.elems )
{
my $work = $orig;
- for ( 1 .. Inf ).map( * % 4 ).kv -> $n, $by
+ for ( 1 .. Inf ).map( * % $n ).kv -> $i, $by
{
$work = $work.rotate: $by;
- return $n + 1
- if $work cmp $orig == Same;
+ return $i + 1
+ if $work cmp $orig == Same;
}
-} \ No newline at end of file
+}
+
+say rotmodN 'xyxx'; \ No newline at end of file