Getting a String from a list of strings
Supporting the maxim "there is always another way to do it":
list = {"M","a","t","h","e","m","a","t","i","c","a"};
StringJoin
accepts lists directly, and in fact is faster this way:
StringJoin @ list
"Mathematica"
Also, StringJoin
has the short form <>
therefore you could also use:
"" <> list
"Mathematica"
Speed check:
large = Characters@ExampleData[{"Text", "LoremIpsum"}];
Do[StringJoin @@ large, {5000}] // Timing
Do[StringJoin @ large, {5000}] // Timing
Do["" <> large, {5000}] // Timing
Version 7.0.1 timings:
{1.622, Null} {0.702, Null} {0.718, Null}
Version 10.1.0 timings:
{0.6864, Null} {0.4524, Null} {0.4524, Null}
Just for something different Fold
works too:
Fold[#1 <> #2 &, "", {"M", "a", "t", "h", "e", "m", "a", "t", "i",
"c", "a"}]
"Mathematica"
Use StringJoin
:
StringJoin @@ {"M", "a", "t", "h", "e", "m", "a", "t", "i", "c", "a"}
"Mathematica"