Skip to content

Conversation

@KyNorthstar
Copy link
Contributor

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()

@KyNorthstar KyNorthstar self-assigned this Nov 30, 2023
@KyNorthstar KyNorthstar added the enhancement New feature or request label Nov 30, 2023
Copy link
Contributor Author

@KyNorthstar KyNorthstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one thing, otherwise LGTM

@KyNorthstar KyNorthstar merged commit a821470 into production Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants