Skip to content

Commit 79f4639

Browse files
committed
user defined example is more better
1 parent 06b5c0c commit 79f4639

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doc/Language/operators.pod

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,18 @@ C<%outer »+» %inner;> only keys of %inner that exist in %outer will occur in
226226
=head2 Reduction Operators
227227
228228
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.
229+
element by element and return the resulting value.
231230
232231
say [+] 1,2,3; # 6
233232
233+
They can be defined as a list prefix operators or will be generated automatically.
234+
235+
multi infix:<[~~]> (@c, &test) is looser(&infix:<~~>) {
236+
gather for @c { take $_ if test($_) }
237+
};
238+
my @l = 1,'a',2,'b';
239+
say @l [~~] {$^a ~~ Str}; # (a b)
240+
234241
For list infix operators, flattening is not done on the input list. This
235242
allowes list operators to become the reduction operator.
236243

0 commit comments

Comments
 (0)