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
Approximate implementation:
def collectby(key_func, iterable, value_func=None, reduce_func=None): collection = defaultdict(list) if reduce_func is None else {} for item in iterable: key = key_func(item) if value_func is not None: item = value_func(item) if reduce_func is None: collection[key].append(item) else: old_item = collection.get(key, sentinel) if old_item is not sentinel: item = reduce_func(old_item, item) collection[key] = item return collection
The text was updated successfully, but these errors were encountered:
Add collectby built-in
2c95ec1
Resolves #620.
No branches or pull requests
Approximate implementation:
The text was updated successfully, but these errors were encountered: