-
Notifications
You must be signed in to change notification settings - Fork 287
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
Add partitions function #276
Conversation
Thanks for the PR. A few comments:
Thanks again. |
👍 |
In my code though the first line was |
It's possible, but then you will get a list of lists of strings with length 1 if the input is the string. To make them strings user will have to write a quite long and slow code. Also, making partitions(list(generator)) |
Just in case: I don't agree with that. I think consuming a generator passed to an iteration tool is totally fine. It always happens anyway. (Also I consider the reference to Zen to be pure demagogy.) |
Now the iterables are supported, but collections are left as is, without converting them to lists. |
I rewrote the code from scratch. Now it's shorter and works 30% faster. |
Partitioning set or interval is a known thing in mathematics. This commit adds a function to do find all partitions of a collection. For more information what is considered a partition, see docstring.
Merged with some additional tests and docstring changes. This will be in the next release. Many thanks! |
@bbayles, I think that the difference between partition and this function should be noted.
I've tried to describe it in a formal way. You've removed that. OK, but then, insert, please, an informal note about this. |
Add partitions function
Partitioning set or interval is a known thing in mathematics. This PR adds a function to do find all partitions of a collection. For more information what is considered a partition, see docstring.
Thanks, Tigran Saluev (http://saluev.com/) for the implementation.
UPD: the code was rewritten from scratch.