Documentation for routine pick

Documentation for routine pick, assembled from the following types:

class List

From List

routine pick

Defined as:

multi sub    pick($count, *@list) returns Seq:D
multi method pick(List:D: $count = 1) returns Mu

Usage:

pick COUNT, LIST
LIST.pick(COUNT)

Returns $count elements chosen at random and without repetition from the invocant. If * is passed as $count, or $count is greater than or equal to the size of the list, then all elements from the invocant list are returned in a random sequence.

Examples:

say <a b c d e>.pick;           # b
say <a b c d e>.pick: 3;        # (c a e)
say  <a b c d e>.pick: *;       # (e d a b c)

role Baggy

From Baggy

method pick

class Range

From Range

method pick

method pick(Range:D:        ) returns Any:D
method pick(Range:D: $number) returns Seq:D

Performs the same function as Range.list.pick, but attempts to optimize by not actually generating the list if it is not necessary.

role Setty

From Setty

method pick

multi method pick($count = 1)

Returns $count elements chosen at random (without repetition) from the set.

If * is passed as $count, or $count is greater than or equal to the size of the set, then all its elements are returned in random order.