Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
doc Reduction Operators
  • Loading branch information
gfldex committed Dec 25, 2015
1 parent e4624b9 commit 46dd698
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion doc/Language/operators.pod
Expand Up @@ -224,7 +224,24 @@ C<%outer »+» %inner;> only keys of %inner that exist in %outer will occur in
say %outer «~» %inner; # {"1" => "ax", "2" => "bz"}
=head2 Reduction Operators
TODO
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.
say [+] 1,2,3; # 6
For list infix operators, flattening is not done on the input list. This
allowes list operators to become the reduction operator.
[X~] (1,2), <a b> # 1,2 X~ <a b>
By default reduction meta operators are eager. To lazily generate values,
prefix the operater with a C<\>. If the non-meta part contains a C<\> already,
quote it with C<[]> (e.g. C<[\[\x]]>).
my $lazy := [\+] 1..*;
say $lazy[^10]; # (1 3 6 10 15 21 28 36 45 55)
=head2 Cross Operators
TODO
Expand Down

0 comments on commit 46dd698

Please sign in to comment.