@@ -1233,23 +1233,24 @@ rather than a constructor.)
1233
1233
1234
1234
multi method pick ( $bag: Int $num = 1 --> Any )
1235
1235
multi method pick ( $bag: Whatever --> Any )
1236
- multi method pickpairs ( $bag: Int $num = 1 --> Any )
1237
- multi method pickpairs ( $bag: Whatever --> Any )
1236
+ multi method pickpairs ( $bag: Int $num = 1 --> Pairs )
1237
+ multi method pickpairs ( $bag: Whatever --> Pairs )
1238
1238
1239
1239
Like an ordinary list C<pick>, but returns keys of the bag weighted by
1240
1240
values, as if the keys were replicated the number of times indicated
1241
- by the corresponding value and then list pick used. C<BagHash> is the
1241
+ by the corresponding value and then list pick used. The C<pickpairs> method
1242
+ does the same, except it returns both key and value. C<BagHash> is the
1242
1243
mutable form of C<Bag>. A C<Bag> responds to hash operators as
1243
1244
if it were a C<Hash of UInt>.
1244
1245
1245
1246
The underlying metaphor for picking is that you're pulling colored
1246
1247
marbles out a bag. (For "picking with replacement" see C<roll> instead.)
1247
- Picking require tracking the temporary state, so the immutable C<Bag> is copied to
1248
- a temporary private C<BagHash>, and the picks are made from that
1248
+ Picking require tracking the temporary state, so the immutable C<Bag> is
1249
+ copied to a temporary private C<BagHash>, and the picks are made from that
1249
1250
using the corresponding C<.grab> or C<.grabpairs> method (see below).
1250
1251
1251
- Each C<.pick> invocation maintains its own private state and has no
1252
- effect on subsequent C<.pick> invocations.
1252
+ Each C<.pick>/C<.pickpairs> invocation maintains its own private state and
1253
+ has no effect on subsequent C<.pick>/C<.pickpairs > invocations.
1253
1254
1254
1255
=item roll
1255
1256
0 commit comments