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,fk]
gives all possible groupings of aspec taken k at a time with the function f applied at each level.
Groupings[aspec,{f1k1,f2k2,…}]
gives all possible groupings in which the function fi is applied to ki elements.
Groupings[aspec,{{f1k1,m1},{f2k2,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.
Details

- Groupings[n,k] can be thought of as generating a list of k-ary expression trees with n leaves.
- In Groupings[{a1,…,an},k], the integer n gives the number of leaves on the tree and k gives the number of children of each node.
- Arities k and ki must be positive integers.
- With an arity specification f->{k,Orderless}, Groupings returns only one representative for each collection of expressions whose tree structure is equivalent up to permutation of the branches of f.