Re: [Python-ideas] Include partitioning in itertools

... Not quite sure if I understand the implementation. Reading this http://mathworld.wolfram.com/BellNumber.html for the given example of 6, it should have 203 possible partitions. What am I missing? [Tim Peters] The ActiveState recipe has nothing to do with set partitions. Instead it returns all ways of breaking a sequence into a sequence of subsequences whose sum (catenation) is the original sequence. If
[Sven R. Kunze] there are N elements in the original sequence, there are 2**(N-1) ways to do that. That's why there are 32 results in the recipe's example output (2**(len("abcdef")-1) == 32). There would be 203 "set partitions" of a 6-element set.
@Tim: you are completely right. Sorry for the confusion referencing this implementation. Forget it.
On Sun, Nov 1, 2015 at 6:37 PM, Brendan Barnwell <brenbarn@brenbarn.net> wrote:
On 2015-11-01 17:58, David Mertz wrote:
Oh, yeah... I see what you are asking for isn't quite the same thing as power set. But still, it's not something you can do in finite time with infinite iterators (nor in tractable time with *large* iterators). So `itertools` isn't where it belongs.
I don't think that reasoning is sound. Itertools already includes several combinatoric generators like permutations and combinations, which aren't computable for infinite iterators and which take intractable time for large finite iterators.
@Brendan: exactly!
participants (1)
-
Albert ten Oever