Some time ago I asked the question about Deleting list members by rule and received a variety of responses.
I have a slightly different data set and here wish to delete list members whose third and fifth elements are "xx" but otherwise are identical to the other members of that element:
lis = {{"a", "b", "c", "d", "e", "f"},
{"g", "h", "i", "j", "l", "m"},
{"a", "b", "xx", "d", "xx", "f"},
{"o", "p", "q", "r", "s", "t"}};
to give:
res = {{"a", "b", "c", "d", "e", "f"},
{"g", "h", "i", "j", "l", "m"},
{"o", "p", "q", "r", "s", "t"}}
Using @eyorble's suggestion, I tried:
lis /. {a___,
Alternatives[
PatternSequence[{b_, c_, d_, e_, f_, g_}, {b_, c_, "xx", e_, "xx",
g_}], PatternSequence[{b_, c_, "xx", e_, "xx", g_}, {b_, c_,
d_, e_, f_, g_}]], w___} :> {a, {b, c, d, e, f, g}, w}
...which fails.
MapAt
'under the hood':DeleteDuplicatesBy[Query[Thread[{3,5}->("xx"&)]]]@lis
$\endgroup$