Skip to content

Document that reduce-like functions use init one or more times #53945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ New library features
Standard library changes
------------------------

* The `init` keyword argument in `reduce(op, itr; init)` and other reduction functions with implementation-defined
associativity (`mapreduce`, `maximum`, `minimum`, `sum`, `prod`, `any`, and `all`)
is now guaranteed to be used for non-empty collections one or more times. This ensures that all calls
to the reducing function `op` have one argument that is either `init` or the result from a
previous `op` evaluation. Previously `init` was explicitly allowed to be omitted from the reduction entirely.
* `gcdx(0, 0)` now returns `(0, 0, 0)` instead of `(0, 1, 0)` ([#40989]).

#### StyledStrings
Expand Down
Loading