Suppose we have a function f
with the Attribute Flat. From my understanding, the following command should return all possible ways of rewriting f[a,b,c]
as a function of two arguments at all levels:
Attributes[f] = {Flat};
f[a,b,c] /. f[x_,y_] /; Print[{x,y}] :> Null;
This command evaluates to
{f[a],f[b,c]}
{f[a,b],f[c]}
{a,f[b,c]}
{f[a,b],c}
{f[a],f[b]}
{a,b}
{f[b],f[c]}
{b,c}
My question: why are the level 2 cases {a,f[b]}
, {f[a],b}
, {b,f[c]}
, and {f[c],b}
not included? Similarly, when the following command is executed,
Attributes[f] = {Flat};
f[a,b,c,d] /. f[x_,y_] /; Print[{x,y}] :> Null;
why does it return two instances of {f[a,b],f[c,d]}
?
I am running Mathematica 11.2 on Ubuntu 18.04.