Skip to content

Commit 880edf3

Browse files
committed
Adds produce refs #1731
1 parent 4963946 commit 880edf3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/Type/Any.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,23 @@ L«C<List.classify>|/type/List#routine_classify» on it.
874874
875875
=head2 method produce
876876
877+
Defined as:
878+
879+
multi method produce(Any:U: & --> Nil)
880+
multi method produce(Any:D: &with)
881+
multi sub produce (&with, +list)
882+
883+
This is similar to L<C<reduce>|/routine/reduce#(List)_routine_reduce>, but
884+
returns a list with the accumulated values instead of a single result.
885+
886+
=for code
887+
<10 5 3>.reduce( &[*] ).say ; # OUTPUT: «150␤»
888+
<10 5 3>.produce( &[*] ).say; # OUTPUT: «(10 50 150)␤»
889+
890+
The last element of the produced list would be the output produced by the
891+
C<.reduce> method.
892+
893+
If it's a class, it will simply return Nil.
877894
878895
=head2 method pairs
879896

0 commit comments

Comments
 (0)