Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11477 > unrolled thread
| Started by | Ulrich Arndt <ulrich.arndt@data2knowledge.de> |
|---|---|
| First post | 2012-08-24 00:56 +0000 |
| Last post | 2012-08-24 00:56 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Group and Replace itens sequence in a list Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2012-08-24 00:56 +0000
| From | Ulrich Arndt <ulrich.arndt@data2knowledge.de> |
|---|---|
| Date | 2012-08-24 00:56 +0000 |
| Subject | Re: Group and Replace itens sequence in a list |
| Message-ID | <k16jfl$ben$1@smc.vnet.net> |
Map[Replace[#, {X, y___} -> {y}] &,
Split[ReplaceRepeated[
l, {x___, a, b, a, y___} -> {x, X, y}], #2 =!= X &]]
Map[DeleteCases[#, X] &,
Split[ReplaceRepeated[
l, {x___, a, b, a, y___} -> {x, X, y}], #2 =!= X &]]
Am 23.08.2012 um 08:52 schrieb Murta:
> Hi All
>
> I have a simple problem that is:
>
> l={1,2,3,a,b,a,4,5,6,a,b,c,7,8,9,a,b,a,10,11,12}
>
> I want to replace all a,b,a sequence by X to get:
>
> l={1,2,3,X,4,5,6,a,b,7,8,9,X,10,11,12}
>
> Then I want to group it by X intervals as
> l={{1,2,3},{4,5,6,a,b,7,8,9},{10,11,12}}
>
> If I don't need to put the intermediate X, even better!
> I think the with pattern, RaplaceAll and DeleteCases I can do It. Some clue?
> Tks
> Murta
>
>
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web