I want to do a replacements such that: f[P1,P2,P3]
goes to P1[a]P2[b]P3[c] g[a,b,c]
where I want the a
,b
,c
to be unique.
More general, I want products like f[P1,P2,P3] f[Q1,Q2,Q3]
to go to P1[a1]P2[b1]P3[c1] g[a1,b1,c1] Q1[a2]Q2[b2]Q3[c2] g[a2,b2,c2]
where again a1
,a2
,b1
,b2
,c1
,c2
are guaranteed to be unique non conflicting characters.
ReplacePart[]
, but this seems like a very unwieldy way of doing what you want here. $\endgroup$f[P1, P2, P3] /. f[a__] :> With[{v = Table[Unique[], Length[{a}]]}, Inner[Compose, {a}, v, Times] g @@ v]
would work. $\endgroup$