File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -900,7 +900,7 @@ function.
900
900
my @years = (2003..2008).map( { Date.new( $_~"-01-01" ) } );
901
901
@years.classify( *.is-leap-year , into => my %leap-years );
902
902
say %leap-years;
903
- # OUTPUT: «{False => [2003-01-01 2005-01-01 2006-01-01 2007-01-01],
903
+ # OUTPUT: «{False => [2003-01-01 2005-01-01 2006-01-01 2007-01-01],
904
904
# True => [2004-01-01 2008-01-01]}»
905
905
906
906
@@ -909,6 +909,22 @@ normalized by the C<Callable> passed with the C<:as> argument, and it can use
909
909
the C < :into > named argument to pass a C < Hash > the results will be classified
910
910
into; in the example above, it's defined on the fly.
911
911
912
+ = head2 method reduce
913
+
914
+ Defined as:
915
+
916
+ multi method reduce(Any:U: & --> Nil)
917
+ multi method reduce(Any:D: &with)
918
+ multi sub reduce (&with, +list)
919
+
920
+ Applying it to a class will always produce Nil.
921
+ Applies its argument (or first argument, in case it's a sub) as an operator to
922
+ all the elements in the object (or second argument), producing a single result.
923
+ The argument must be an infix operator or take, in any case, two positional
924
+ arguments.
925
+
926
+ (1..13).reduce( &[*] ).say; # OUTPUT: «6227020800»
927
+
912
928
= head2 method produce
913
929
914
930
Defined as:
You can’t perform that action at this time.
0 commit comments