Skip to content

Commit

Permalink
the named argument to .pick is now called :replace
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Nov 6, 2009
1 parent 6670e70 commit 830e2cf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/setting/Any-list.pm
Expand Up @@ -48,7 +48,7 @@ class Any is also {
}
}
multi method pick(Int $num is copy = 1, :$repl) {
multi method pick(Int $num is copy = 1, :$replace) {

$num=floor($num);

Expand All @@ -57,7 +57,7 @@ class Any is also {
}

my @l;
if ($repl) {
if ($replace) {
@l := @.list;
}
else {
Expand All @@ -68,14 +68,14 @@ class Any is also {
while ($num > 0 and @l.elems > 0) {
my $idx = floor(@l.elems.rand());
take @l[$idx];
@l.splice($idx,1) unless $repl;
@l.splice($idx,1) unless $replace;
--$num;
}
}
}

multi method pick(Whatever $, :$repl) {
die "Infinite lazy pick not implemented" if $repl;
multi method pick(Whatever $, :$replace) {
die "Infinite lazy pick not implemented" if $replace;
@.pick(@.elems);
}

Expand Down Expand Up @@ -192,12 +192,12 @@ our List multi map(Code $expr, *@values) {
@values.map($expr)
}

multi pick(Int $num, :$repl, *@values) {
@values.pick($num,:repl($repl));
multi pick(Int $num, :$replace, *@values) {
@values.pick($num, :$replace);
}

multi pick(Whatever $, :$repl, *@values) {
@values.pick(*,:repl($repl));
multi pick(Whatever $, :$replace, *@values) {
@values.pick(*,:$replace);
}

multi max(Code $by, *@values) {
Expand Down

0 comments on commit 830e2cf

Please sign in to comment.