Prev: trying to use InputField as a continually attentive
Next: Finding order of all numbers in a Finite Field
From: Dr. S. S. Tong on 4 Apr 2010 07:47 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
From: Tomas Garza on 4 Apr 2010 07:47 Make sure each letter in your {h,e,l,l,o} is a string, i.e., that it is actually {"h", "e", "l", "l", "o"} Then use StringJoin: In[1]:== StringJoin[{"h", "e", "l", "l", "o"}] Out[1]== "hello" Do the same for {"This", " ", "is", " ", "a", " ", "test", " ", "message"}, but remember to type the spaces between each word. In[2]:== StringJoin[{"This", " ", "is", " ", "a", " ", "test", " ", "message"}] Out[2]== "This is a test message" Tomas > Date: Sat, 3 Apr 2010 06:09:05 -0500 > From: ebaugh(a)illinois.edu > Subject: Combining elements of a list > To: mathgroup(a)smc.vnet.net > > > How could I go from: > to> {h,e,l,l,o} > {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 > >
From: Christoph Lhotka on 5 Apr 2010 08:01 Hello, I already saw many versions, which I like very much, just another one to demonstrate Mathematica=C2=B4s string manipulation capabilities: data=={{t,h,i,s},{i,s},{a},{t,e,s,t},{m,e,s,s,a,g,e}} StringReplace[ToString[data],{" "|","|"{"->"","}"->" "}]//StringTrim all the best, chr On Sa, 3.04.2010, 13:09, ebaugh(a)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 On Sa, 3.04.2010, 13:09, ebaugh(a)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 > > > > > -- Mag. Christoph Lhotka University of Vienna / Institute for Astronomy Tuerkenschanzstrasse 17, A-1180 Vienna, Austria fon. +43 (1) 4277 51841 mail. lhotka(a)astro.univie.ac.at
From: Murray Eisenberg on 5 Apr 2010 08:01 Riffle: that's a function new in Mathematica 6 that I missed completely. Neat! On 4/4/2010 7:43 AM, Albert Retey wrote: > Hi, > >> 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" >> > If you want to join strings, use StringJoin :-) > > this works if the entries are symbols: > > letters={{t, h, i, s}, {i, s}, {a}, {t, e, s, t}, {m, e, s, s, a, > g, e}} > > StringJoin[Riffle[Map[ToString,letters,{2}], " "]] > > if the entries are strings already, this would be enough: > > letters = {{"t", "h", "i", "s"}, {"i", "s"}, {"a"}, {"t", "e", "s", > "t"}, {"m", "e", "s", "s", "a", "g", "e"}} > > StringJoin[Riffle[letters, " "]] > > hth, > > albert > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
First
|
Prev
|
Pages: 1 2 3 Prev: trying to use InputField as a continually attentive Next: Finding order of all numbers in a Finite Field |