MathGroup Archive 2005

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

Search the Archive

Re: List Partition


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