Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement Bag|Mix.grabpairs, oddly enough exactly the same as Setty.grab
  • Loading branch information
lizmat committed Oct 6, 2013
1 parent 889892a commit c6b15dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/Baggy.pm
Expand Up @@ -108,6 +108,10 @@ my role Baggy does QuantHash {
}, 1 .. $todo;
}

method grabpairs($count = 1) {
(%!elems{ %!elems.keys.pick($count) }:delete).list;
}

proto method classify-list(|) { * }
multi method classify-list( &test, *@list ) {
fail 'Cannot .classify an infinite list' if @list.infinite;
Expand Down
4 changes: 3 additions & 1 deletion src/core/Setty.pm
Expand Up @@ -64,7 +64,9 @@ my role Setty does QuantHash {

method list() { %!elems.values }
method pairs() { %!elems.values.map({ $_ => True }) }
method grab($count = 1) { (%!elems{ %!elems.keys.pick($count) }:delete).list }
method grab($count = 1) {
(%!elems{ %!elems.keys.pick($count) }:delete).list;
}
method pick($count = 1) { %!elems.values.pick($count) }
method roll($count = 1) { %!elems.values.roll($count) }

Expand Down

0 comments on commit c6b15dc

Please sign in to comment.