I have a function `f(x,y)` for which `f(x,y) != f(y,x)`.

I would like to generalise the following for any `n`:

n=1: `C = A`  

n=2: `C = f(A,B) + f(B,A)`  

n=3: `C = f(A,f(B,B)) + f(B,f(A,B)) + f(B,f(B,A))`  

n=4: `C = f(A,f(B,f(B,B)) + f(B,f(A,f(B,B)) + f(B,f(B,f(A,B)) + f(B,f(B,f(B,A))`  

The pattern is:

* There are `n` terms.
* Each term has `n-1` calls to `f()`.
* Every term is composed of all `B`s except for one `A` in each position.

Is these a simple way to perform this so I can write a function that computes `C` for any `n` (given also a `A` and `B`)? i.e. `C = general(A, B, n)`