Re: Combining elements of a list
- To: mathgroup at smc.vnet.net
- Subject: [mg108866] Re: Combining elements of a list
- From: "Dr. S. S. Tong" <sstong at phy.cuhk.edu.hk>
- Date: Sun, 4 Apr 2010 07:47:21 -0400 (EDT)
On Sat, 3 Apr 2010 06:09:05 -0500 (EST), ebaugh wrote
> How could I go from:
> {h,e,l,l,o}
> to
> {hello}?
>
> That is the first step of what I am really looking to do. Which is
> to go from:
> {{t,h,i,s},{i,s},{a},{t,e,s,t},{m,e,s,s,a,g,e}}
> to
> "this is a test message"
>
> Thanks all,
> Jason Ebaugh
The following will do (assuming the elements in your lists are strings):
StringJoin[{"h", "e", "l", "l", "o"}]
StringJoin @@
Riffle[{{"t", "h", "i", "s"}, {"i", "s"}, {"a"}, {"t", "e", "s",
"t"}, {"m", "e", "s", "s", "a", "g", "e"}}, " "]
Shiu-sing