|
[Date Index]
[Thread Index]
[Author Index]
Re: Converting a list of strings to a single space-delimited string
- To: mathgroup at smc.vnet.net
- Subject: [mg122853] Re: Converting a list of strings to a single space-delimited string
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Sat, 12 Nov 2011 07:35:39 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j9geh9$ovb$1@smc.vnet.net> <j9is6c$8i3$1@smc.vnet.net>
"Dr. Wolfgang Hintze" <weh at snafu.de> schrieb im Newsbeitrag
news:j9is6c$8i3$1 at smc.vnet.net...
>
> "Andrew DeYoung" <adeyoung at andrew.cmu.edu> schrieb im Newsbeitrag
> news:j9geh9$ovb$1 at smc.vnet.net...
>> Hi,
>>
>> 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?
>>
>> Thanks so much.
>>
>> Andrew DeYoung
>> Carnegie Mellon University
>>
>
> It can be easily done:
> (* define data *)
> lst = {"1", "2", "3"}
> {"1", "2", "3"}
>
> (* perform operation *)
> StringJoin @@ lst
> "123"
>
> (* check type of result *)
> Head[%]
> String
>
> Regards,
> Wolfgang
>
>
Sorry, but my solution is incorrect, because I missed the required " "
(space) between the numbers.
Others have already given a correct solution here.
Regards,
Wolfgang
Prev by Date:
Re: dynamic nested loops
Next by Date:
Re: FindRoot with algebraic expressions
Previous by thread:
Re: Converting a list of strings to a single space-delimited string
Next by thread:
Re: Converting a list of strings to a single space-delimited string
|