I'm looking for a function similar to the one in the question below, but for the more general problem of set partitions without restricting the set size.

NextKSizePartition, or how to partition a set into subsets of size $k$ but incrementally

Combinatorica provides the function SetPartitions which returns all the set partitions of the given set. The output size corresponds with the bell numbers which grow quite quickly. I would like to iterate over all set partitions without generating the entire list. Does there already exist a function with this capacity?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.