aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-08-27 14:38:50 +0100
committerGitHub <noreply@github.com>2019-08-27 14:38:50 +0100
commit968a2011df76057b4b231cd59e188060bde0f042 (patch)
tree5ecd5c3c589de606273d5785b2196d7e3c99553b
parent362bbeeeed6e5cc41282a90d0b4b1212babc73b3 (diff)
parent61323da16c45b076e2c18e83fd830fbc6d7f9d62 (diff)
downloadperlweeklychallenge-club-968a2011df76057b4b231cd59e188060bde0f042.tar.gz
perlweeklychallenge-club-968a2011df76057b4b231cd59e188060bde0f042.tar.bz2
perlweeklychallenge-club-968a2011df76057b4b231cd59e188060bde0f042.zip
Merge pull request #565 from Scimon/master
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-] |$_ } )
}