Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Re-add support for List.pick(Inf)
Apparently, that was supposed to work but did not have a spectest.
  • Loading branch information
lizmat committed Oct 3, 2015
1 parent 18b7f1e commit 880d3c8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/core/List.pm
Expand Up @@ -658,17 +658,14 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
my $elems = self.elems;
$elems ?? nqp::atpos($!reified, $elems.rand.floor) !! Nil;
}
multi method pick(List:D: Whatever) {
multi method pick(List:D: $number is copy) {
fail X::Cannot::Lazy.new(:action('.pick from')) if self.is-lazy;
my Int $elems = self.elems;
$elems ?? self!pick($elems,$elems) !! ()
}
multi method pick(List:D: Int() $number) {
fail X::Cannot::Lazy.new(:action('.pick from')) if self.is-lazy;
my Int $elems = self.elems;
$elems ?? self!pick($elems,$number min $elems) !! ()
}
method !pick(\elems,\number) {
return () unless $elems;

$number = nqp::istype($number,Whatever) || $number == Inf
?? $elems
!! $number.Int min $elems;
Seq.new(class :: does Iterator {
has $!list;
has Int $!elems;
Expand Down Expand Up @@ -705,7 +702,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
}
IterationEnd
}
}.new(self,elems,number))
}.new(self,$elems,$number))
}

proto method roll(|) is nodal { * }
Expand Down

0 comments on commit 880d3c8

Please sign in to comment.