File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,24 @@ C<%outer »+» %inner;> only keys of %inner that exist in %outer will occur in
224
224
say %outer «~» %inner; # {"1" => "ax", "2" => "bz"}
225
225
226
226
= head2 Reduction Operators
227
- TODO
227
+
228
+ Reduction operators apply any infix operator, surrounded by C < [ > and C < ] > ,
229
+ element by element and return the resulting value. They can be defined as a
230
+ list prefix operators or will be generated automatically.
231
+
232
+ say [+] 1,2,3; # 6
233
+
234
+ For list infix operators, flattening is not done on the input list. This
235
+ allowes list operators to become the reduction operator.
236
+
237
+ [X~] (1,2), <a b> # 1,2 X~ <a b>
238
+
239
+ By default reduction meta operators are eager. To lazily generate values,
240
+ prefix the operater with a C < \ > . If the non-meta part contains a C < \ > already,
241
+ quote it with C < [] > (e.g. C < [\[\x]] > ).
242
+
243
+ my $lazy := [\+] 1..*;
244
+ say $lazy[^10]; # (1 3 6 10 15 21 28 36 45 55)
228
245
229
246
= head2 Cross Operators
230
247
TODO
You can’t perform that action at this time.
0 commit comments