Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
user defined example is more better
  • Loading branch information
gfldex committed Dec 25, 2015
1 parent 06b5c0c commit 79f4639
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions doc/Language/operators.pod
Expand Up @@ -226,11 +226,18 @@ C<%outer »+» %inner;> only keys of %inner that exist in %outer will occur in
=head2 Reduction Operators
Reduction operators apply any infix operator, surrounded by C<[> and C<]>,
element by element and return the resulting value. They can be defined as a
list prefix operators or will be generated automatically.
element by element and return the resulting value.
say [+] 1,2,3; # 6
They can be defined as a list prefix operators or will be generated automatically.
multi infix:<[~~]> (@c, &test) is looser(&infix:<~~>) {
gather for @c { take $_ if test($_) }
};
my @l = 1,'a',2,'b';
say @l [~~] {$^a ~~ Str}; # (a b)
For list infix operators, flattening is not done on the input list. This
allowes list operators to become the reduction operator.
Expand Down

0 comments on commit 79f4639

Please sign in to comment.