WLJS LogoWLJS Notebook

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 of a1, …, an taken k at a time.
  • Groupings[{{a1, a2, …}, {b1, b2, …}, …}, k] gives the combination of all possible groupings of each of the lists ai, bi, … taken k at a time.
  • Groupings[aspec, f -> k] gives all possible groupings of aspec taken k at a time with the function f applied at each level.
  • Groupings[aspec, {f1 -> k1, f2 -> k2, …}] gives all possible groupings in which the function fi is applied to ki elements.
  • Groupings[aspec, {{f1 -> k1, m1}, {f2 -> k2, m2}, …}] allows at most mi occurrences in a given grouping of fi applied to ki elements.
  • Groupings[aspec, kspec, h] wraps the function h around 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.

On this page