aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Proctor <simon.proctor@zpg.co.uk>2019-08-27 13:01:21 +0100
committerSimon Proctor <simon.proctor@zpg.co.uk>2019-08-27 13:01:21 +0100
commit61323da16c45b076e2c18e83fd830fbc6d7f9d62 (patch)
treeed0f9e417eb7ed80b661f008a43ab4e3c34e170f
parent5ad76f91ac4058f097fe564ab1baada91cab6588 (diff)
downloadperlweeklychallenge-club-61323da16c45b076e2c18e83fd830fbc6d7f9d62.tar.gz
perlweeklychallenge-club-61323da16c45b076e2c18e83fd830fbc6d7f9d62.tar.bz2
perlweeklychallenge-club-61323da16c45b076e2c18e83fd830fbc6d7f9d62.zip
Move the test for n into the parameters
-rw-r--r--challenge-023/simon-proctor/perl6/ch-1.p65
1 files changed, 2 insertions, 3 deletions
diff --git a/challenge-023/simon-proctor/perl6/ch-1.p6 b/challenge-023/simon-proctor/perl6/ch-1.p6
index 06f12c70ab..53d5100294 100644
--- a/challenge-023/simon-proctor/perl6/ch-1.p6
+++ b/challenge-023/simon-proctor/perl6/ch-1.p6
@@ -9,10 +9,9 @@ multi sub MAIN( Bool :h(:$help) where so * ) {
#| Calculate the Nth forward difference series of the given values
multi sub MAIN(
- UInt $n, #= Order to calculate
- *@vals where @vals.all ~~ Int #= List of Integers to calculate from
+ UInt $n, #= Order to calculate must be between 0 and 1 less than the list length
+ *@vals where @vals.all ~~ Int && 0 <= $n <= @vals.elems-1 #= List of Integers to calculate from
) {
- die "N must between 1 and {@vals.elems-1}" unless 0 < $n <= @vals.elems-1;
for ^$n {
@vals = @vals.rotor(2=>-1).map( { [R-] |$_ } )
}