I use groupings as below:
Join[
Groupings[IntegerPartitions[3], {A -> {2, Orderless}, B -> {2, Orderless}}],
{x}]
Which generates:
{A[2, 1], B[2, 1], A[A[1, 1], 1], A[B[1, 1], 1], B[A[1, 1], 1], B[B[1, 1], 1], 3}
How can A
be restricted so A
is not applied to arguments that are both atomic? That is. I want the output to be:
{B[2, 1], A[B[1, 1], 1], B[B[1, 1], 1], 3}
Of course, I can remove the results in which A
is applied to two atoms (i.e. two positive integers) after generating the list:
{A[2, 1], B[2, 1], A[A[1, 1], 1], A[B[1, 1], 1], B[A[1, 1], 1], B[B[1, 1], 1], 3}
Is it possible to do prevent generating the cases where A
applies to two atoms (integers in this case) by adapting the given code:
Join[
Groupings[IntegerPartitions[3], {A -> {2, Orderless}, B -> {2, Orderless}}],
{x}]
For example, by adding a condition
/, ! AtomQ[x] && !AtomQ[y]
for an application A[x,y]
?
B[A[1,1],1]
? $\endgroup$