Skip to content

Commit

Permalink
(Bag|BagHash).pickpairs are more like .grabpairs
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 18, 2013
1 parent d0e9368 commit 155abd8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions S32-setting-library/Containers.pod
Original file line number Diff line number Diff line change
Expand Up @@ -1238,10 +1238,9 @@ rather than a constructor.)

Like an ordinary list C<pick>, but returns keys of the bag weighted by
values, as if the keys were replicated the number of times indicated
by the corresponding value and then list pick used. The C<pickpairs> method
does the same, except it returns both key and value. C<BagHash> is the
mutable form of C<Bag>. A C<Bag> responds to hash operators as
if it were a C<Hash of UInt>.
by the corresponding value and then list pick used. C<BagHash> is the
mutable form of C<Bag>. A C<Bag> responds to hash operators as if it were
a C<Hash of UInt>.

The underlying metaphor for picking is that you're pulling colored
marbles out a bag. (For "picking with replacement" see C<roll> instead.)
Expand All @@ -1252,6 +1251,9 @@ using the corresponding C<.grab> or C<.grabpairs> method (see below).
Each C<.pick>/C<.pickpairs> invocation maintains its own private state and
has no effect on subsequent C<.pick>/C<.pickpairs> invocations.

The C<.pickpairs> version returns the grabbed values as a list of C<Pair>
objects, whose keys are the keys and whose values are the replication values.

=item roll

multi method roll ( $bag: Int $num = 1 --> Any )
Expand Down

0 comments on commit 155abd8

Please sign in to comment.