-
-
Notifications
You must be signed in to change notification settings - Fork 823
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
Filter: an alternative helper that returns both accepted and rejected items #135
Comments
Shouldn't partitions := lo.PartitionBy[int, int]([]int{1, 2, 3, 4}, func(x int) int {
return x%2
}) As for the reject isn't it good enough to use lo.Filter with the opposite comparison function? |
Other names:
|
That's a good point. I think I slightly prefer the name |
I found grpIsEven := lo.GroupBy[int]([]int{1, 3}, func(x int) bool {
return x%2 == 0
})
even := grpIsEven[true]
odd := grpIsEven[false]
fmt.Printf("even[%d] odd[%d] even %v odd %v", len(even), len(odd), even, odd) prints even[0] odd[2] even [] odd [1 3] |
Close this issue. FilterReject has been released: #472 |
Example:
I would name it
lo.Filter2
but it looks weird. Does anyone have a better idea?A
lo.RejectXXX
helper would be excellent too.The text was updated successfully, but these errors were encountered: