# How to joint symbolic expressions together [duplicate]

I want to joint symbolic expressions together to create a another symbolic expressions.

one way to do that is as follows:

symb = ToExpression[ToString[#1] <> ToString[#2]] & @@@ {{x, y}, {y,
z}, {x, z}}

(*{xy, yz, xz}*)


is there any better way to do this? something like the StringJoin "<>" for strings

-

## marked as duplicate by Mr.Wizard♦Jul 2 '14 at 6:56

You may want to look at SymbolName and Symbol, but I think you are going to have to use string functions as you have done in your example. –  mfvonh Jun 25 '14 at 23:14
So, what will the result of joining Sin[x] with 1+x+x^2 ? It can not be Sin[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 be x as the () are stripped off. I think the semantics of joining expressions needs more thought. –  Nasser Jun 25 '14 at 23:26
Symbol[SymbolName@# ~~ SymbolName@#2] & @@@ {{x, y}, {y, z}, {x, z}}? –  kglr Jun 25 '14 at 23:27
@Nasser that is not what I want. I want to create symbols from symbols in my work. but for your example, will be neat to create Sin from S,i,n? –  Algohi Jun 25 '14 at 23:37
It seems we've been down this road before: How to 'merge' a list like FromDigits, but with a mixture of numbers and symbols? -- I shall mark this question as a duplicate unless someone disagrees. –  Mr.Wizard Jun 25 '14 at 23:43

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}

-
Thanks Mr.Wizard. –  Algohi Jun 25 '14 at 23:39