Re: List Partition
- To: mathgroup at smc.vnet.net
- Subject: [mg53915] Re: List Partition
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Fri, 4 Feb 2005 04:11:10 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 2/2/05 at 6:25 AM, chocolatez at gmail.com (zak) wrote:
>what could i do to partition the list:
>a={cat,E,in,the,hat,E,okay,fine,E} into
>a={{cat},{{in},{the},{hat}},{{okay},{fine}}}
>ie: every word in a sublist , and E determine the end of a
>sentence (a bigger list). zak
One way to do it would be as follows:
In[2]:=
a = ToString /@ {cat, E, in, the, hat, E, okay, fine, E}
Out[2]=
{"cat", "E", "in", "the", "hat", "E", "okay", "fine", "E"}
In[3]:=
str = StringJoin @@ (StringJoin[#1, " "] & ) /@ a
Out[3]=
"cat E in the hat E okay fine E "
In[4]:=
ReadList[StringToStream[str], Word, RecordLists -> True,
RecordSeparators -> {"E"}]
Out[4]=
{{"cat"}, {"in", "the", "hat"}, {"okay", "fine"}}
--
To reply via email subtract one hundred and four