Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to write down Mathematica with a string such as:

share|improve this question
?*String* will list the available string functions if you need more information. – image_doctor Jun 19 '12 at 19:47
up vote 12 down vote accepted

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

Also, StringJoin has the short form <> therefore you could also use:

"" <> list

Speed check:

large = Characters@ExampleData[{"Text", "LoremIpsum"}];

Do[StringJoin @@ large, {5000}] // Timing

Do["" <> large, {5000}] // Timing
{1.528, Null}

{0.671, Null}
share|improve this answer
Good maxim :) You and Jagra seem to have the same one :) – Öskå Jun 19 '12 at 19:21
""<> list ...Elegant! – Jagra Jun 19 '12 at 19:24
@Öskå Jagra's answer shows something else: it would still work if StringJoin could only accept two strings. Fold is a very useful function to know. See my example here. – Mr.Wizard Jun 19 '12 at 19:25
@Jagra thanks :D – Mr.Wizard Jun 19 '12 at 19:25
Brilliant. I definitely need to get used with # and @@ and & and such things, is there a good "course" about this on S.E.? – Öskå Jun 19 '12 at 19:36

Use StringJoin:

StringJoin @@ {"M", "a", "t", "h", "e", "m", "a", "t", "i", "c", "a"}


share|improve this answer
ah, been looking for one hour. Feels dumb Thanks! – Öskå Jun 19 '12 at 18:41
No problem, we've all experienced the same thing, good luck. – image_doctor Jun 19 '12 at 18:42

Just for something different Fold works too:

Fold[#1 <> #2 &, "", {"M", "a", "t", "h", "e", "m", "a", "t", "i", 
  "c", "a"}]

share|improve this answer

If we're going to get silly about it:

TextRecognize @ Graphics @ MapIndexed[Text[Style[#1, 50], {#2[[1]], 0}] &, list]
share|improve this answer

At risk of taking "even more" too far here is a method that does not use any function with "String" in the name:

list = {"M", "a", "t", "h", "e", "m", "a", "t", "i", "c", "a"};

FromCharacterCode @ Flatten @ ToCharacterCode @ list

Or using an export function:

ExportString[{list}, "Table", "FieldSeparators" -> ""]

Or a formatting function:

ToString @ Row @ list
share|improve this answer
Sheer vulpinism, that's what it is :) – István Zachar Jun 19 '12 at 21:37
+1 for: 'ToString @ Row @ list'. This seems to me the most interesting of all the solutions offered for the question, because you've taken such an original view of the problem while maintaing your customary clarity and conciseness. Nice! – Jagra Jun 20 '12 at 14:03

Just to stretch even more the limits of "there is always another way to do it" (Mr.Wizard), here is a way to NOT use StringJoin at all:

chars = {"M", "a", "t", "h", "e", "m", "a", "t", "i", "c", "a"};
Fold[StringInsert[#1, #2, -1] &, "", Flatten@chars]

And a simpler one:

StringExpression @@ chars

Using built-in path functions to complicate things (use ToFileName if prior to version 7):

StringReplace[FileNameJoin@chars, "\\" -> ""]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.