I think you need to be very careful--you might not be able to get what you want. You mentioned that you're getting a list of symbols from a function. Let's mimic that:
symbolGenerator[] := {x1, x2, x3, x4};
symbolGenerator[]
(* returns {x1, x2, x3, x4} *)
Okay, let's say you wanted to use Unique on these so that you avoid name collisions. Well, it should work fine if none of the symbols were defined.
Unique[symbolGenerator[]]
(* {x1$7526, x2$7526, x3$7526, x4$7526} *)
But let's try again in a situation where there's actually a name collision:
ClearAll[x1, x2, x3, x4, symbolGenerator];
symbolGenerator[] := {x1, x2, x3, x4};
x3 = 17;
Unique[symbolGenerator[]]
Now we get a message saying "17 is not a symbol or a valid symbol name"
.
If you implemented symbolGenerator
, then you could return strings instead of symbols; you could wrap the output in Hold or maybe Unevaluated; you could add a context directly to the symbols; or you could use Unique to start with. For example:
symbolGenerator[] := Unique[{"x1", "x2", "x3", "x4"}]
(* or *)
symbolGenerator[] := Symbol[StringJoin["special`", #]] & /@ {"x1", "x2", "x3", "x4"}
If you didn't implement symbolGenerator
, then we'd probably need to know more about that function before making concrete suggestions.
{\[Formax1],\[Formax2],\[Formalx3],\[Formalx4]}
gives a syntax error (V12.3). $\endgroup$Symbol /@ StringReplace[ToString /@ list, "x" -> "\[FormalX]"]
give you what you want? $\endgroup$