Skip to content

Commit

Permalink
Document .pick(**)
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Mar 7, 2023
1 parent 9f10710 commit 63ca40c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/Type/List.rakudoc
Expand Up @@ -737,6 +737,7 @@ against a L<Signature|/type/Signature>.

multi sub pick($count, *@list --> Seq:D)
multi method pick(List:D: $count --> Seq:D)
multi method pick(List:D: * --> Seq:D)
multi method pick(List:D: --> Mu)

If C<$count> is supplied: Returns C<$count> elements chosen at random
Expand All @@ -754,6 +755,16 @@ Examples:
say <a b c d e>.pick: 3; # OUTPUT: «(c a e)␤»
say <a b c d e>.pick: *; # OUTPUT: «(e d a b c)␤»

As of the 2021.06 release of the Rakudo compiler, it is also possible to
specify C<**> (aka C<HyperWhatever>) as the count.

multi method pick(List:D: ** --> Seq:D)

In that case, C<.pick> will start picking again on the original list
after it has been exhausted, again and again, indefinitely.

say <a b c>.pick(**).head(10); # OUTPUT: «((a c b c a b b c a b))␤»

=head2 routine roll

multi sub roll($count, *@list --> Seq:D)
Expand Down

0 comments on commit 63ca40c

Please sign in to comment.