We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I propose to add the following general-purpose functions to the maps package:
maps
// FilterFunc returns an iterator with filtered key-value pairs. func FilterFunc[M ~map[K]V, K comparable, V any](m M, filter func(K, V) bool) iter.Seq2[K, V] { return func(yield func(K, V) bool) { for k, v := range m { if filter(k, v) { if !yield(k, v) { return } } } } }
// TransformValuesFunc modifies values with a user-defined function. func TransformValuesFunc[M ~map[K]V, K comparable, V any](m M, transform func(K, V) V) { for k, v := range m { m[k] = transform(k, v) } }
The text was updated successfully, but these errors were encountered:
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Sorry, something went wrong.
This is just xiter.Filter(f, maps.All(m)) and xiter.Map(f, maps.All(m)) from #61898 No need for specialized functions
xiter.Filter(f, maps.All(m))
xiter.Map(f, maps.All(m))
Duplicate of #61898
No branches or pull requests
Proposal Details
I propose to add the following general-purpose functions to the
maps
package:The text was updated successfully, but these errors were encountered: