A bit more terse than your own code:
Symbol /@ ToString /@ Row /@ {{x, y}, {y, z}, {x, z}}
{xy, yz, xz}
Or using SymbolName
as suggested by mfvonh in the comments:
Symbol[""<>(SymbolName /@ #)] & /@ {{x, y}, {y, z}, {x, z}}
{xy, yz, xz}
However, both these and yours will fail if a Symbol such as x
already has a value.
To get around that you will need to introduce holding somewhere, perhaps like this:
SetAttributes[symbolJoin, HoldAll]
symbolJoin[s__Symbol] := Symbol @ ToString @ HoldForm @ Row[{s}]
Now:
x = 7;
List @@ symbolJoin @@@ Hold[{x, y}, {y, z}, {x, z}]
{xy, yz, xz}
Or:
symbolJoin @@@ Unevaluated[{{x, y}, {y, z}, {x, z}}]
{xy, yz, xz}
SymbolName
andSymbol
, but I think you are going to have to use string functions as you have done in your example. $\endgroup$Sin[x]
with1+x+x^2
? It can not beSin[x] 1 +x +x^2
? Is that what you really want? May be there is need to add( )
around each expression then before joining. However, there is issue where M sometimes removes those( )
around single expression as not needed. Try typing(x)
in the notebook, the result will bex
as the()
are stripped off. I think the semantics of joining expressions needs more thought. $\endgroup$Symbol[SymbolName@# ~~ SymbolName@#2] & @@@ {{x, y}, {y, z}, {x, z}}
? $\endgroup$