Documentation for routine pairs
Documentation for routine pairs, assembled from the following types:
method pairs(--> TODO)
sub pairs( --> Seq)method pairs(List: --> Seq)
Returns a sequence of pairs, with the indexes as keys and the list values as values.
<a b c>.pairs # (0 => a 1 => b 2 => c)
method pairs(Baggy: --> Seq)
Returns all elements and their respective weights as a Seq of
Pairs where the key is the element itself and the value is the weight of that element.
my = bag <bacon eggs bacon>;my = .pairs;say .sort; # OUTPUT: «(bacon => 2 eggs => 1)␤»
multi method pairs(Capture: --> Seq)
Returns all arguments, the positional followed by the named, as a Seq of Pairs. Positional arguments have their respective ordinal value, starting at zero, as key while the named arguments have their names as key.
my Capture = \(2, 3, apples => (red => 2));say .pairs; # OUTPUT: «(0 => 2 1 => 3 apples => red => 2)␤»
method pairs(Map: --> Seq)
Seq of all pairs in the Map.
my = Map.new('a' => (2, 3), 'b' => 17);say .pairs; # OUTPUT: «(a => (2 3) b => 17)␤»
multi method pairs(Pair:)
Returns a list of one
Pair, namely this one.
my = (Perl => 6);say .pairs.WHAT; # OUTPUT: «(List)␤»say .pairs; # OUTPUT: «(Pair)␤»