This introduces a .reduce(_:)
function to sequences whose elements conform to AdditiveArithmetic
which assumes you're reducing into .zero
:
// Before
bunchaNumbers.reduce(into: 0) { $0 = max($0, $1) }
// After
bunchaNumbers.reduce { $0 = max($0, $1) }
This also adds a convenience function .sum()
, build on this new reducer:
// Before
bunchaNumbers.reduce(into: 0, +=)
// After
bunchaNumbers.sum()
Patch Notes
1.3.0
- #12: Added
.reduce
which assumes reducing into 0 when elements are additive
- #12: Added
Full Changelog: 1.2.1...1.3.0