aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-345/kjetillll/perl/ch-1.pl2
1 files changed, 1 insertions, 1 deletions
diff --git a/challenge-345/kjetillll/perl/ch-1.pl b/challenge-345/kjetillll/perl/ch-1.pl
index 9ef8dece4a..0301c3c7a4 100644
--- a/challenge-345/kjetillll/perl/ch-1.pl
+++ b/challenge-345/kjetillll/perl/ch-1.pl
@@ -1,5 +1,5 @@
sub peaks {
- grep { ( $_[$_-1] // -Inf ) < $_[$_] > ( $_[$_+1] // -Inf ) } 0 .. $#_
+ grep { ( $_ == 0 ? -Inf : $_[$_-1] ) < $_[$_] > ( $_ == $#_ ? -Inf : $_[$_+1] ) } 0 .. $#_
}
use Test::More tests => 5;
is_deeply [ peaks(1, 3, 2) ], [1];