Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6364 > unrolled thread
| Started by | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| First post | 2011-11-11 09:58 +0000 |
| Last post | 2011-11-11 09:58 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Converting a list of strings to a single space-delimited string Bill Rowe <readnews@sbcglobal.net> - 2011-11-11 09:58 +0000
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Date | 2011-11-11 09:58 +0000 |
| Subject | Re: Converting a list of strings to a single space-delimited string |
| Message-ID | <j9irk6$8e3$1@smc.vnet.net> |
On 11/10/11 at 6:53 AM, adeyoung@andrew.cmu.edu (Andrew DeYoung)
wrote:
>I know that the command StringSplit can be used to convert a single
>space-delimited string to a list of strings. For example,
>B = "1 2 3"; mylist = StringSplit[B]
>gives a list mylist such that mylist = {"1", "2", "3"}.
>But what if I would like to go in the reveres direction -- convert
>{"1", "2", "3"} to "1 2 3"? Is there a good way to do this, other
>than using a For loop and concatenating the elements of the list
>together?
In[1]:= data = ToString /@ Range[3];
In[2]:= StringJoin @@ Riffle[data, " "]
Out[2]= 1 2 3
For what it is worth, I've been using Mathematica on a daily
basis for the past 10-20 years. And the only times I can recall
using For were to show someone just how much slower code runs in
Mathematica when using For instead of functional programming.
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web