Given a set S and a partition L=\{l_1\geq l_2\cdots\}, the method returns the list of partitions of the set S of type L, i.e. representations of S as S=S_1\cup S_2\cup\cdots, where the S_i's are disjoint subsets of S having t_i elements.
i1 : partitions(set{1,2,3,4},{2,1,1}) o1 = {set {set {1, 2}, set {3}, set {4}}, set {set {1, 3}, set {2}, set {4}}, set {set {1, 4}, set {2}, set {3}}, set {set {1}, ---------------------------------------------------------------------------------------------------------------------------- set {2, 3}, set {4}}, set {set {1}, set {2, 4}, set {3}}, set {set {1}, set {2}, set {3, 4}}} o1 : List |
i2 : partitions(set{a,b,c,d,e},new Partition from {3,2}) o2 = {set {set {a, b}, set {c, d, e}}, set {set {a, c, d}, set {b, e}}, set {set {a, e}, set {b, c, d}}, set {set {a, c, e}, set ---------------------------------------------------------------------------------------------------------------------------- {b, d}}, set {set {a, d}, set {b, c, e}}, set {set {a, b, c}, set {d, e}}, set {set {a, d, e}, set {b, c}}, set {set {a, c}, ---------------------------------------------------------------------------------------------------------------------------- set {b, d, e}}, set {set {a, b, d}, set {c, e}}, set {set {a, b, e}, set {c, d}}} o2 : List |