txt: ## pick.md
  pick
  
  Combined from primary sources listed below.
  
  # [In List](#___top "go to top of document")[§](#(List)_routine_pick "direct link")
  
  See primary documentation
  [in context](/type/List#routine_pick)
  for **routine pick**.
  
  ```raku
  multi        pick($count, *@list --> Seq:D)
  multi method pick(List:D: $count --> Seq:D)
  multi method pick(List:D: --> Mu)
  multi method pick(List:D: Callable $calculate --> Seq:D)
  ```
  
  If `$count` is supplied: 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; i.e. they are returned shuffled.
  
  In *method* form, if `$count` is omitted: Returns a single random item from the list, or Nil if the list is empty
  
  Examples:
  
  ```raku
  say <a b c d e>.pick;           # OUTPUT: «b␤»
  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 `**` (aka [`HyperWhatever`](/type/HyperWhatever)) as the count.
  
  In that case, `.pick` will start picking again on the original list after it has been exhausted, again and again, indefinitely.
  
  ```raku
  say <a b c>.pick(**).head(10);  # OUTPUT: «((a c b c a b b c a b))␤»
  ```
  
  # [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_pick "direct link")
  
  See primary documentation
  [in context](/type/Baggy#method_pick)
  for **method pick**.
  
  ```raku
  multi method pick(Baggy:D: --> Any)
  multi method pick(Baggy:D: $count --> Seq:D)
  ```
  
  Like an ordinary list [pick](/type/List#routine_pick), but returns keys of the invocant weighted by their values, as if the keys were replicated the number of times indicated by the corresponding value and then list pick used. The underlying metaphor for picking is that you're pulling colored marbles out a bag. (For "picking with replacement" see [roll](#method_roll) instead). If `*` is passed as `$count`, or `$count` is greater than or equal to the [total](#method_total) of the invocant, then `total` elements from the invocant are returned in a random sequence.
  
  Note that each `pick` invocation maintains its own private state and has no effect on subsequent `pick` invocations.
  
  ```raku
  my $breakfast = bag <eggs bacon bacon bacon>;
  say $breakfast.pick;                              # OUTPUT: «eggs␤»
  say $breakfast.pick(2);                           # OUTPUT: «(eggs bacon)␤»
  
  say $breakfast.total;                             # OUTPUT: «4␤»
  say $breakfast.pick(*);                           # OUTPUT: «(bacon bacon bacon eggs)␤»
  ```
  
  # [In enum Bool](#___top "go to top of document")[§](#(enum_Bool)_routine_pick "direct link")
  
  See primary documentation
  [in context](/type/Bool#routine_pick)
  for **routine pick**.
  
  ```raku
  multi method pick(Bool:U: --> Bool:D)
  multi method pick(Bool:U: $count --> Seq:D)
  ```
  
  Returns a random pick of `True` and/or `False`.
  
  If it's called without an argument then it returns just one pick:
  
  ```raku
  say Bool.pick;                                    # OUTPUT: «True␤»
  ```
  
  If it's called with a `$count` of one then it returns a [`Seq`](/type/Seq) with just one pick:
  
  ```raku
  say Bool.pick(1);                                 # OUTPUT: «(False)␤»
  ```
  
  If `$count` is `*` or greater than or equal to two then it returns a [`Seq`](/type/Seq) with *two* elements -- either `True` then `False`, or `False` then `True`:
  
  ```raku
  say Bool.pick(*);                                 # OUTPUT: «(False True)␤»
  ```
  
  # [In role Enumeration](#___top "go to top of document")[§](#(role_Enumeration)_method_pick "direct link")
  
  See primary documentation
  [in context](/type/Enumeration#method_pick)
  for **method pick**.
  
  ```raku
  multi method pick(::?CLASS:U:)
  multi method pick(::?CLASS:U: \n)
  multi method pick(::?CLASS:D: *@pos)
  ```
  
  It works on the defined class, selecting one element and eliminating it.
  
  ```raku
  say Norse-gods.pick() for ^3;  # OUTPUT: «Þor␤Freija␤Oðin␤»
  
  ```
  
  # [In Range](#___top "go to top of document")[§](#(Range)_method_pick "direct link")
  
  See primary documentation
  [in context](/type/Range#method_pick)
  for **method pick**.
  
  ```raku
  multi method pick(Range:D:         --> Any:D)
  multi method pick(Range:D: $number --> 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.
  
  # [In Any](#___top "go to top of document")[§](#(Any)_method_pick "direct link")
  
  See primary documentation
  [in context](/type/Any#method_pick)
  for **method pick**.
  
  ```raku
  multi method pick(--> Any)
  multi method pick($n --> Seq)
  ```
  
  Coerces the invocant to a [`List`](/type/List) by applying its [`.list`](/routine/list) method and uses [`List.pick`](/type/List#routine_pick) on it.
  
  ```raku
  my Range $rg = 'α'..'ω';
  say $rg.pick(3); # OUTPUT: «(β α σ)␤»
  ```
  
  # [In role Setty](#___top "go to top of document")[§](#(role_Setty)_method_pick "direct link")
  
  See primary documentation
  [in context](/type/Setty#method_pick)
  for **method pick**.
  
  ```raku
  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 (shuffled).
  
  # [In role Mixy](#___top "go to top of document")[§](#(role_Mixy)_method_pick "direct link")
  
  See primary documentation
  [in context](/type/Mixy#method_pick)
  for **method pick**.
  
  ```raku
  method pick($?)
  ```
  
  Throws an exception. The feature is not supported on the type, since there's no clear value to subtract from non-integral weights, to make it work.
  