From 61323da16c45b076e2c18e83fd830fbc6d7f9d62 Mon Sep 17 00:00:00 2001 From: Simon Proctor Date: Tue, 27 Aug 2019 13:01:21 +0100 Subject: Move the test for n into the parameters --- challenge-023/simon-proctor/perl6/ch-1.p6 | 5 ++--- 1 file 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-] |$_ } ) } -- cgit