MathGroup Archive 2006

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

Search the Archive

Re: question about Split[...]


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}


  • Prev by Date: Re: SetOptions with Column
  • Next by Date: Increment and AddTo
  • Previous by thread: Re: question about Split[...]
  • Next by thread: Re: question about Split[...]