Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[List] reduce
  • Loading branch information
moritz committed Jun 10, 2012
1 parent afb84de commit 47dbe4a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/List.pod
Expand Up @@ -217,5 +217,17 @@ If C<&by> accepts only one argument, the list elements are sorted
according to C<< by($a) cmp by($b) >>. The return values of C<&by> are
cached, so that C<&by> is only called once per list element.
=head3 reduce
multi sub reduce(&with, *@elems)
multi method reduce(List:D: &with)
Applies C<&with> to the first and the second value of the list, then to result
of that calculation and the third value and so on. Returns a single item
generated that way.
Note that C<reduce> is an implicit loop, and thus responds to C<next>, C<last>
and C<redo> statements.
=end pod

0 comments on commit 47dbe4a

Please sign in to comment.