Re: question about Split[...]

*To*: mathgroup at smc.vnet.net*Subject*: [mg64544] Re: question about Split[...]*From*: "Borut Levart" <BoLe79 at gmail.com>*Date*: Wed, 22 Feb 2006 05:58:27 -0500 (EST)*References*: <dte21e$rbp$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, I would use the Split function without the test, but then trim its results. What do you say? In= lst = {a, a, a, a, b, a, c, c, c, b, b, b, b, b, b, c, c, d, a, a, a, a, a, a, a, a, a, a}; Module[{k = 3, d}, If[d = Length[#]; d > k, {Take[#, k], Sequence @@ Take[#, d - k]}, #] & /@ Split[s] // Flatten[#, 1] &] Out= {{a, a, a}, a, b, a, c, c, c, {b, b, b}, b, b, b, c, c, d, {a, a, a}, a, a, a, a, a, a, a}