Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 07900b5cac6781e3491e6c0232f0abdf2757b96b 1 parent 95a1946
sorear authored June 25, 2012

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. 6  lib/CORE.setting
6  lib/CORE.setting
@@ -1684,7 +1684,7 @@ my class List is Cool does Positional {
1684 1684
         if $cmp_.count == 1 {
1685 1685
             $cmp = sub (\x, \y) { $cmp_(x) cmp $cmp_(y) }
1686 1686
         }
1687  
-        my $min = self[0];
  1687
+        my $min = self[0] // return Inf;
1688 1688
         for @(self) {
1689 1689
             $min = $_ if $cmp($_, $min) < 0;
1690 1690
         }
@@ -1696,7 +1696,7 @@ my class List is Cool does Positional {
1696 1696
         if $cmp_.count == 1 {
1697 1697
             $cmp = sub (\x, \y) { $cmp_(x) cmp $cmp_(y) }
1698 1698
         }
1699  
-        my $max = self[0];
  1699
+        my $max = self[0] // return -Inf;
1700 1700
         for @(self) {
1701 1701
             $max = $_ if $cmp($_, $max) > 0;
1702 1702
         }
@@ -1708,7 +1708,7 @@ my class List is Cool does Positional {
1708 1708
         if $cmp_.count == 1 {
1709 1709
             $cmp = sub (\x, \y) { $cmp_(x) cmp $cmp_(y) }
1710 1710
         }
1711  
-        my $min = self[0];
  1711
+        my $min = self[0] // return Inf .. -Inf;
1712 1712
         my $max = self[0];
1713 1713
         for @(self) {
1714 1714
             $min = $_ if $cmp($_, $min) < 0;

0 notes on commit 07900b5

Please sign in to comment.
Something went wrong with that request. Please try again.