Groupings
Groupings[n, k] gives a list of all possible groupings of 1, …, n taken k at a time.
Groupings[{a1, …, an}, k]gives all possible groupings ofa1, …, antakenkat a time.Groupings[{{a1, a2, …}, {b1, b2, …}, …}, k]gives the combination of all possible groupings of each of the listsai, bi, …takenkat a time.Groupings[aspec, f -> k]gives all possible groupings ofaspectakenkat a time with the functionfapplied at each level.Groupings[aspec, {f1 -> k1, f2 -> k2, …}]gives all possible groupings in which the functionfiis applied tokielements.Groupings[aspec, {{f1 -> k1, m1}, {f2 -> k2, m2}, …}]allows at mostmioccurrences in a given grouping offiapplied tokielements.Groupings[aspec, kspec, h]wraps the functionharound each grouping generated.
Examples
Groupings[3, 2]Groupings[{a, b, c}, 2]Groupings[{x, y, z}, f -> 2]Please visit the official Wolfram Language Reference for more details.