@@ -1164,10 +1164,46 @@ is returned.
1164
1164
1165
1165
X < String concatenation operator > .
1166
1166
1167
- Coerces both arguments to L < Str > and concatenates them. If both arguments are L < Buf > , a combined buffer is returned.
1167
+ Coerces both arguments to L < Str > and concatenates them. If both arguments are
1168
+ L < Buf|/type/Buf > , a combined buffer is returned.
1168
1169
1169
1170
say 'ab' ~ 'c'; # OUTPUT: «abc»
1170
1171
1172
+ = head2 infix C « <∘> »
1173
+
1174
+ multi sub infix:<∘>()
1175
+ multi sub infix:<∘>(&f)
1176
+ multi sub infix:<∘>(&f, &g --> Block:D)
1177
+
1178
+ X < Function combinator operator >
1179
+
1180
+ The function composition operator C « infix:<∘> » or C « infix:<o> » combines two
1181
+ functions, so that the left function is called with the return value of the
1182
+ right function. If the L « C < .count > |/routine/count» of the left function is
1183
+ greater than 1, the return value of the right function will be
1184
+ L < slipped|/type/Slip > into the left function.
1185
+
1186
+ Both C < .count > and C < .arity > of the RHS will be maintained.
1187
+
1188
+ sub f($p){ say 'f'; $p / 2 }
1189
+ sub g($p){ say 'g'; $p * 2 }
1190
+
1191
+ my &composed = &f ∘ &g;
1192
+ say composed 2; # OUTPUT: «gf2»
1193
+ # equivalent to:
1194
+ say 2.&g.&f;
1195
+ # or to:
1196
+ say f g 2;
1197
+
1198
+ = begin code
1199
+ sub f($a, $b, $c) { [~] $c, $b, $a }
1200
+ sub g($str){ $str.comb }
1201
+ my &composed = &f ∘ &g;
1202
+ say composed 'abc'; # OUTPUT: «cba»
1203
+ # equivalent to:
1204
+ say f |g 'abc';
1205
+ = end code
1206
+
1171
1207
= head1 Junctive AND (all) Precedence
1172
1208
1173
1209
= head2 infix C « & »
0 commit comments