You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, the C<.Mix> coercer (or its functional form, C<Mix()>) can be
52
-
called on an existing object to coerce it to a C<Mix>. Its semantics depend on
53
-
the type and contents of the object. In general it evaluates the object in list
54
-
context and creates a mix with the resulting items as elements, although for
55
-
Hash-like objects or Pair items, only the keys become elements of the mix, and
56
-
the (cumulative) values become the associated numeric weights:
51
+
Alternatively, the C<.Mix> coercer (or its functional form, C<Mix()>)
52
+
can be called on an existing object to coerce it to a C<Mix>. Its
53
+
semantics depend on the type and contents of the object. In general it
54
+
evaluates the object in list context and creates a mix with the
55
+
resulting items as elements, although for Hash-like objects or Pair
56
+
items, only the keys become elements of the mix, and the (cumulative)
57
+
values become the associated numeric weights:
57
58
58
59
my $n = ("a", "a", "b" => 0, "c" => 3.14).Mix;
59
60
say $n.keys.map(&WHAT); # OUTPUT: «((Str) (Str))»
@@ -82,27 +83,33 @@ Defined as:
82
83
83
84
method Bag (--> Bag:D)
84
85
85
-
Coerces the C<Mix> to a L«C<Bag>|/type/Bag». The weights are convert to L«C<Int>|/type/Int»,
86
-
which means the number of keys in the resulting C<Bag> can be fewer than in the
87
-
original C<Mix>, if any of the weights are negative or truncate to zero.
86
+
Coerces the C<Mix> to a L«C<Bag>|/type/Bag». The weights are convert to
87
+
L«C<Int>|/type/Int», which means the number of keys in the resulting
88
+
C<Bag> can be fewer than in the original C<Mix>, if any of the weights
89
+
are negative or truncate to zero.
88
90
89
91
=head2method BagHash
90
92
91
93
Defined as:
92
94
93
95
method BagHash (--> BagHash:D)
94
96
95
-
Coerces the C<Mix> to a L«C<BagHash>|/type/BagHash». The weights are convert to L«C<Int>|/type/Int»,
96
-
which means the number of keys in the resulting C<BagHash> can be fewer than in the
97
-
original C<Mix>, if any of the weights are negative or truncate to zero.
97
+
Coerces the C<Mix> to a L«C<BagHash>|/type/BagHash». The weights are
98
+
convert to L«C<Int>|/type/Int», which means the number of keys in the
99
+
resulting C<BagHash> can be fewer than in the original C<Mix>, if any of
100
+
the weights are negative or truncate to zero.
98
101
99
102
=head2method reverse
100
103
101
-
I<Note>: This method is inherited from L<Any|/type/Any#routine_reverse>, however, C<Mix>es do not have an inherent order and you should not trust it returning a consistent output.
104
+
I<Note>: This method is inherited from L<Any|/type/Any#routine_reverse>,
105
+
however, C<Mix>es do not have an inherent order and you should not trust
106
+
it returning a consistent output.
102
107
103
108
=head2Note on order
104
109
105
-
Same as the other elements in the L<Bag/Mix suite|/language/setbagmix>, order is not guaranteed or consistent and you shouldn't rely on methods like C<reverse> above returning always the same result.
110
+
Same as the other elements in the L<Bag/Mix suite|/language/setbagmix>,
111
+
order is not guaranteed or consistent and you shouldn't rely on methods
112
+
like C<reverse> above returning always the same result.
0 commit comments