aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-078/simon-proctor/raku/ch-1.raku10
-rw-r--r--challenge-078/simon-proctor/raku/ch-2.raku16
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-078/simon-proctor/raku/ch-1.raku b/challenge-078/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..82dc9168fe
--- /dev/null
+++ b/challenge-078/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,10 @@
+#!/usr/bin/env raku
+
+use v6;
+
+# Given a list of number print all those larger than all the others left in the list
+sub MAIN(
+ *@a where { .all ~~ Int } #= List of integers
+) {
+ @a.kv.map( -> $i, $v { $v >= all(@a[$i..*]) ?? $v !! Empty }).join(", ").say;
+}
diff --git a/challenge-078/simon-proctor/raku/ch-2.raku b/challenge-078/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..2829c53442
--- /dev/null
+++ b/challenge-078/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+
+use v6
+my %*SUB-MAIN-OPTS = :named-anywhere;
+#| Given a list of values and some named pivot points rotate the list
+#| so that the given pivot is first in the list
+sub MAIN (
+ *@values where { $_.elems > 0 }, #= List to rotate
+ # There's a weird Emacs Raku mode bug with < hence <= elems-1
+ :p(:@pivots)! where { .all ~~ UInt && .all <= @values.elems-1 }, #= List of values to rotate
+) {
+ for @pivots -> $p {
+ [ |@values[$p..*], |@values[0..^$p] ].say
+ }
+
+}