diff options
| author | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-09-14 09:57:35 +0100 |
|---|---|---|
| committer | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-09-14 09:57:35 +0100 |
| commit | 4f728663b92c5191dc2680f062086c75b1ed5495 (patch) | |
| tree | 0489e43e32135b72c51598c0f859d3d81ed44e27 | |
| parent | 18189fb64bb99d145aab27a97790ad225a1e805d (diff) | |
| download | perlweeklychallenge-club-4f728663b92c5191dc2680f062086c75b1ed5495.tar.gz perlweeklychallenge-club-4f728663b92c5191dc2680f062086c75b1ed5495.tar.bz2 perlweeklychallenge-club-4f728663b92c5191dc2680f062086c75b1ed5495.zip | |
List rotations
| -rw-r--r-- | challenge-078/simon-proctor/raku/ch-2.raku | 16 |
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 + } + +} |
