MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Combining elements of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108863] Re: Combining elements of a list
  • From: Simon <simonjtyler at gmail.com>
  • Date: Sun, 4 Apr 2010 07:46:46 -0400 (EDT)
  • References: <hp7735$krb$1@smc.vnet.net>

This is a nice easy one... you're bound to get lots of replies.
It's not clear that you start off with characters (in Mathematica,
that's strings of length one) - So I'll assume not.
Here's my attempt at producing what you want (I've converted the
outputs to Raw InputForm so that you can see the quote marks):

In[1]:= test1={{t,h,i,s},{i,s},{a},{t,e,s,t},{m,e,s,s,a,g,e}}
Out[1]={{t, h, i, s}, {i, s}, {a}, {t, e, s, t}, {m, e, s, s, a, g,
e}}

In[2]:= test2=Map[ToString,test1,{2}]
Out[2]={{"t", "h", "i", "s"}, {"i", "s"}, {"a"}, {"t", "e", "s", "t"},
{"m", "e", "s", "s", "a", "g", "e"}}

In[3]:= StringJoin[Riffle[test2," "]]
Out[3]="this is a test message"

Simon

On Apr 3, 6:59 pm, eba... at illinois.edu 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



  • Prev by Date: Re: Combining elements of a list
  • Next by Date: Re: Combining elements of a list
  • Previous by thread: Re: Combining elements of a list
  • Next by thread: Re: Combining elements of a list