txt: ## pairs.md
  pairs
  
  Combined from primary sources listed below.
  
  # [In List](#___top "go to top of document")[§](#(List)_routine_pairs "direct link")
  
  See primary documentation
  [in context](/type/List#routine_pairs)
  for **routine pairs**.
  
  ```raku
  sub    pairs($list --> Seq:D)
  method pairs(List:D: --> Seq:D)
  ```
  
  Returns a sequence of pairs, with the indexes as keys and the list values as values.
  
  ```raku
  say <a b c>.pairs;   # OUTPUT: «(0 => a 1 => b 2 => c)␤»
  ```
  
  # [In role Baggy](#___top "go to top of document")[§](#(role_Baggy)_method_pairs "direct link")
  
  See primary documentation
  [in context](/type/Baggy#method_pairs)
  for **method pairs**.
  
  ```raku
  method pairs(Baggy:D: --> Seq:D)
  ```
  
  Returns all elements and their respective weights as a [`Seq`](/type/Seq) of [`Pair`](/type/Pair)s where the key is the element itself and the value is the weight of that element.
  
  ```raku
  my $breakfast = bag <bacon eggs bacon>;
  my $seq = $breakfast.pairs;
  say $seq.sort;                                    # OUTPUT: «(bacon => 2 eggs => 1)␤»
  ```
  
  # [In Capture](#___top "go to top of document")[§](#(Capture)_method_pairs "direct link")
  
  See primary documentation
  [in context](/type/Capture#method_pairs)
  for **method pairs**.
  
  ```raku
  multi method pairs(Capture:D: --> Seq:D)
  ```
  
  Returns all arguments, the positional followed by the named, as a [`Seq`](/type/Seq) of [`Pair`](/type/Pair)s. Positional arguments have their respective ordinal value, starting at zero, as key while the named arguments have their names as key.
  
  ```raku
  my Capture $c = \(2, 3, apples => (red => 2));
  say $c.pairs; # OUTPUT: «(0 => 2 1 => 3 apples => red => 2)␤»
  ```
  
  # [In Map](#___top "go to top of document")[§](#(Map)_method_pairs "direct link")
  
  See primary documentation
  [in context](/type/Map#method_pairs)
  for **method pairs**.
  
  ```raku
  method pairs(Map:D: --> Seq:D)
  ```
  
  Returns a [`Seq`](/type/Seq) of all pairs in the Map.
  
  ```raku
  my $m = Map.new('a' => (2, 3), 'b' => 17);
  say $m.pairs; # OUTPUT: «(a => (2 3) b => 17)␤»
  ```
  
  # [In Pair](#___top "go to top of document")[§](#(Pair)_method_pairs "direct link")
  
  See primary documentation
  [in context](/type/Pair#method_pairs)
  for **method pairs**.
  
  ```raku
  multi method pairs(Pair:D:)
  ```
  
  Returns a list of one `Pair`, namely this one.
  
  ```raku
  my $p = (Raku => "d");
  say $p.pairs.^name; # OUTPUT: «List␤»
  say $p.pairs[0];    # OUTPUT: «Raku => d␤»
  ```
  
  # [In Any](#___top "go to top of document")[§](#(Any)_method_pairs "direct link")
  
  See primary documentation
  [in context](/type/Any#method_pairs)
  for **method pairs**.
  
  ```raku
  multi method pairs(Any:U:)
  multi method pairs(Any:D:)
  ```
  
  Returns an empty [`List`](/type/List) if the invocant is a type object:
  
  ```raku
  say Num.pairs; # OUTPUT: «()␤»
  ```
  
  For a value object, it converts the invocant to a [`List`](/type/List) via the `list` method and returns the result of [List.pairs](/type/List#routine_pairs) on it.
  
  ```raku
  <1 2 2 3 3 3>.Bag.pairs.say;# OUTPUT: «(1 => 1 3 => 3 2 => 2)␤»
  ```
  
  In this case, every element (with weight) in a bag is converted to a pair.
  