aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-078/simon-proctor/raku/ch-2.raku16
1 files changed, 16 insertions, 0 deletions
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..c2b3a10ffe
--- /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 <= @values.elems-1 }, #= List of values to rotate
+) {
+ for @pivots -> $p {
+ [ |@values[$p..*], |@values[0..^$p] ].say
+ }
+
+}