MathGroup Archive 2005

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

Search the Archive

Re: List Partition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53896] Re: List Partition
  • From: "Valeri Astanoff" <astanoff at yahoo.fr>
  • Date: Wed, 2 Feb 2005 18:10:37 -0500 (EST)
  • References: <ctqe1f$sf7$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In[1]:=
a={"cat","E","in","the","hat","E","okay","fine","E"};

In[2]:=
r1={x_/;x!="E",y___} -> {"E",x,y};

In[3]:=
r2={x___,y_/;y!="E"} -> {x,y,"E"};

In[4]:=
r3={x___,y_/;y!="E","E",z_/;z!="E",t___} -> {x,y,"E","E",z,t};

In[5]:=
r4={x___,"E",y___/;y!="E","E",z___}->{x,{y},z};

In[6]:=
r5={x___,y_List/;Length[y]>1&&Length@Dimensions[y] == 1,
z___} :> {x,List/@y,z};

In[7]:=
b=a/.r1/.r2//.r3//.r4//.r5
Out[7]=
{{cat},{{in},{the},{hat}},{{okay},{fine}}}


  • Prev by Date: Re: Problem with a sum
  • Next by Date: marching Squares Algorithm
  • Previous by thread: Re: Re: List Partition
  • Next by thread: Re: List Partition