Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: List Partition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53932] Re: [mg53895] List Partition
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Fri, 4 Feb 2005 04:11:57 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

 

>-----Original Message-----
>From: zak [mailto:chocolatez at gmail.com] 
To: mathgroup at smc.vnet.net
>Sent: Wednesday, February 02, 2005 12:26 PM
>To: mathgroup at smc.vnet.net
>Subject: [mg53932] [mg53895] List Partition
>
>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
>
>

In[14]:= r1 = Split[a, #1 =!= "E" &]
Out[14]=
{{"cat", "E"}, {"in", "the", "hat", "E"}, {"okay", "fine", "E"}}

In[15]:= r2 = Drop[r1, {}, {-1}]
Out[15]=
{{"cat"}, {"in", "the", "hat"}, {"okay", "fine"}}

In[16]:= Map[List, r2, {2}]
Out[16]=
{{{"cat"}}, {{"in"}, {"the"}, {"hat"}}, {{"okay"}, {"fine"}}}


--
Hartmut Wolf


  • Prev by Date: Re: List Partition
  • Next by Date: Re: Problem with matching.
  • Previous by thread: Re: List Partition
  • Next by thread: Re: List Partition