Fast set partition iterators#

sage.combinat.set_partition_iterator.set_partition_iterator(base_set)[source]#

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]]]
>>> from sage.all import *
>>> from sage.combinat.set_partition_iterator import set_partition_iterator
>>> list(set_partition_iterator([Integer(1),-Integer(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)[source]#

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]]]
>>> from sage.all import *
>>> from sage.combinat.set_partition_iterator import set_partition_iterator_blocks
>>> list(set_partition_iterator_blocks([Integer(1),-Integer(1),x], Integer(2)))                          # needs sage.symbolic
[[[1, x], [-1]], [[1], [-1, x]], [[1, -1], [x]]]