I was looking for a way of, given two variables called A and B, obtaining a new variable called AB. My idea was doing simple pattern matching, e.g.
A B/.x_ y_->ToString[x]<>ToString[y]
But this rule outputs xy instead of the desired AB. Is there a way of obtaining the desired output? Thank you for your time.


A B /. x_ y_ :> ToString[x] <> ToString[y]gives"AB"-- see http://mathematica.stackexchange.com/q/22917/121 – Mr.Wizard Jan 30 '17 at 11:41