Fast set partition iterators#

sage.combinat.set_partition_iterator.set_partition_iterator(base_set)#

A fast iterator for the set partitions of the base set, which returns lists of lists instead of set partitions types.

EXAMPLES:

sage: from sage.combinat.set_partition_iterator import set_partition_iterator
sage: list(set_partition_iterator([1,-1,x]))                                    # needs sage.symbolic
[[[1, -1, x]],
 [[1, -1], [x]],
 [[1, x], [-1]],
 [[1], [-1, x]],
 [[1], [-1], [x]]]
sage.combinat.set_partition_iterator.set_partition_iterator_blocks(base_set, k)#

A fast iterator for the set partitions of the base set into the specified number of blocks, which returns lists of lists instead of set partitions types.

EXAMPLES:

sage: from sage.combinat.set_partition_iterator import set_partition_iterator_blocks
sage: list(set_partition_iterator_blocks([1,-1,x], 2))                          # needs sage.symbolic
[[[1, x], [-1]], [[1], [-1, x]], [[1, -1], [x]]]