BooleanCat / go-functional

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

[Feature 🔨]: Support `Exclude`ing of iterators via methods #60

Closed BooleanCat closed 1 year ago

BooleanCat commented 1 year ago

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

Excludeing an iterator is achieved by using the iter package's Exclude function. This can lead to deeply nested code that can be difficult to read. The issue belongs to a series of issues that remedy that problem. See #55 for more details.

Describe the solution you'd like

Each iterator should allow Excludeing via a method rather than the function iter.Exclude.

For example, this test:

func ExampleExclude() {
    filtered := iter.Exclude[int](iter.Lift([]int{0, 1, 0, 2}), filters.IsZero[int]).Collect()
    fmt.Println(filtered)
    // Output: [1, 2]
}

Could instead read like:

func ExampleFilter() {
    filtered := iter.Lift([]int{0, 1, 0, 2}).Exclude(filters.IsZero[int]).Collect()
    fmt.Println(filtered)
    // Output: [1 2]
}

Does this incur a breaking change?

No.

Do you intend to build this feature yourself?

No - I'd like to offer this to first-time contributors ideally.

Checklist

See #57 for an example of where this was implemented for Collect.

BooleanCat commented 1 year ago

This is being picked up by @William-Young-97