Consider the following groupings code:
Groupings[IntegerPartitions[3], {A -> 2, B -> 2}]
This generates:
{A[2, 1], B[2, 1], A[A[1, 1], 1], A[1, A[1, 1]], A[B[1, 1], 1],
A[1, B[1, 1]], B[A[1, 1], 1], B[1, A[1, 1]], B[B[1, 1], 1],
B[1, B[1, 1]]}
In other words, the expressions with heads A and heads B over the arguments given by integer partition are generated.
These expressions correspond to expression trees of which Orderless versions can be obtained (``Orderless" in the sense of Mathematica, for trees, i.e. essentially trees identified up to permutations of children of a node).
Is there an Orderless version for Groupings?
I tried something like:
Groupings[IntegerPartitions[3], {A -> 2, B -> 2}, Orderless]
Or:
Groupings[IntegerPartitions[3], {A -> 2, B -> 2, Orderless}]
both of which produce errors.
I would like to obtain an efficient way to only keep ``Orderless versions of the expressions'' (as determined by the orderless versions of their expression trees).
Note that a distinction of heads matters, i.e. A and B are not interchangeable).
SetAttributes[{A,B}, Orderless]
work? $\endgroup$Groupings[IntegerPartitions[3], {foo -> 2, bar -> 2}, Sort]
? $\endgroup$