BooleanCat / go-functional

go-functional is a library of iterators to augment the standard library
MIT License
405 stars 23 forks source link

[Feature 🔨]: Max and min consumers #120

Closed BooleanCat closed 2 months ago

BooleanCat commented 2 months ago

Is your feature request related to a problem? Please describe.

It ought to be possible to find the max or min values of an iterator without storing the entire iterator in memory (collecting it).

Describe the solution you'd like

An iterator of comparable types can have the max or min values found using a function that consumes the iterator.

Provide code snippets to show how this new feature might be used.

numbers := iter.Take(iter.Count(), 15)
fmt.Println(iter.Max(numbers))
// Output: 14

Does this incur a breaking change?

No.

Do you intend to build this feature yourself?

Yes.