As a general rule, don't treat lists as strings. Pretend that they don't have a string representation. (The string representation is only useful for serialization, debugging, but not for the user).
To convert text (especially user-input) to a list use split
.
To convert it back, use join
.
Sou you want:
puts [join $A]
Background:
A list have the sideeffect of escaping all meta-characters used by Tcl so no further subsitution takes place when you eval
this list. This is a very important property for generating Callbacks/code that will be later executed:
set userinput [gets stdin]
set code [list puts $userinput]
eval $code
No matter what the user enters here, the output is always the same as the user entered, without any substitution.
If the $
would not be escaped, then an evaluation would try to substitute $mx_0
, which will most likly fail.