File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,29 @@ L<Mixy>.
21
21
22
22
= head2 method pick
23
23
24
- = comment TODO
24
+ Defined as:
25
+
26
+ multi method pick(Baggy:D:) returns Any
27
+ multi method pick(Baggy:D: $count) returns Seq:D
28
+
29
+ Like an ordinary list L < pick|/type/List#routine_pick > , but returns keys
30
+ of the invocant weighted by their values, as if the keys were replicated
31
+ the number of times indicated by the corresponding value and then list
32
+ pick used. The underlying metaphor for picking is that you're pulling
33
+ colored marbles out a bag. (For "picking with replacement" see
34
+ L < roll|#method roll > instead). If C < * > is passed as C < $count > , or C < $count > is
35
+ greater than or equal to the L < total|#method total > of the invocant, then
36
+ C < total > elements from the invocant are returned in a random sequence.
37
+
38
+ Note that each C < pick > invocation maintains its own private state and has
39
+ no effect on subsequent C < pick > invocations.
40
+
41
+ my $breakfast = bag <eggs bacon bacon bacon>;
42
+ say $breakfast.pick; # eggs
43
+ say $breakfast.pick(2); # (eggs bacon)
44
+
45
+ say $breakfast.total; # 4
46
+ say $breakfast.pick(*); # (bacon bacon bacon eggs)
25
47
26
48
= head2 method pickpairs
27
49
You can’t perform that action at this time.
0 commit comments