Permalink
Browse files

Handle 0-arg [min] and [max], fixes #71

  • Loading branch information...
sorear committed Jun 25, 2012
1 parent 95a1946 commit 07900b5cac6781e3491e6c0232f0abdf2757b96b
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/CORE.setting
View
@@ -1684,7 +1684,7 @@ my class List is Cool does Positional {
if $cmp_.count == 1 {
$cmp = sub (\x, \y) { $cmp_(x) cmp $cmp_(y) }
}
- my $min = self[0];
+ my $min = self[0] // return Inf;
for @(self) {
$min = $_ if $cmp($_, $min) < 0;
}
@@ -1696,7 +1696,7 @@ my class List is Cool does Positional {
if $cmp_.count == 1 {
$cmp = sub (\x, \y) { $cmp_(x) cmp $cmp_(y) }
}
- my $max = self[0];
+ my $max = self[0] // return -Inf;
for @(self) {
$max = $_ if $cmp($_, $max) > 0;
}
@@ -1708,7 +1708,7 @@ my class List is Cool does Positional {
if $cmp_.count == 1 {
$cmp = sub (\x, \y) { $cmp_(x) cmp $cmp_(y) }
}
- my $min = self[0];
+ my $min = self[0] // return Inf .. -Inf;
my $max = self[0];
for @(self) {
$min = $_ if $cmp($_, $min) < 0;

0 comments on commit 07900b5

Please sign in to comment.