Skip to content

Commit a14449d

Browse files
committed
[List] roll, pick
1 parent 560b0ce commit a14449d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/List.pod

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,25 @@ Same as C<.join(' ')>.
147147
148148
Same as C<.elems>.
149149
150+
=head3 pick
151+
152+
multi method pick(List:D:, $count = 1)
153+
154+
Returns a list of random, non-repeating list elements of C<$count>
155+
elements (or a single element if C<$count> is 1).
156+
157+
If a C<*> is passed to C<$count>, all elements are returned in a random
158+
order.
159+
160+
=head3 roll
161+
162+
multi method roll(List:D:, $count = 1)
163+
164+
Returns a lazy list of C<$count> elements, each randomly selected from the
165+
list. Each random choice is made indepently, like a separate die roll
166+
where each die face is a list element.
167+
168+
If C<*> is passed to C<$count>, a lazy, infinite list of randomly chosen
169+
elements from the original list.
170+
150171
=end pod

0 commit comments

Comments
 (0)