-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
proposal: x/exp/slices: addition of Count function #57798
Comments
It would help to point to some existing code that would benefit from this function. Thanks. |
This type of usecase seems like it would be better covered by a count := set.Intersect(set.Of(a...), set.Of(b...)).Size() |
I think we are still waiting on a compelling use case for this. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
API
For inputs of nil or an empty slice, the expected output is 0. For an input where v is not in s, the expected output is 0. For all other (happy path) cases, the expected output is equal to the number of elements in s that are equal to v.
Rationale
No nuanced rationale here, a couple times in the near past I have been looking for such a
Count
method when working with slices. Interested in gauging interest of whether such an additional API is worth adding to theexp/slices
library. It is trivial to implement when needed, but also a nice convenience function to have.Note that this proposal can also be easily extended to cover
CountFunc
if we wish to maintain the usual symmetry that is found in theexp/slices
library.The text was updated successfully, but these errors were encountered: