Skip to main content
edited tags
Link
kglr
  • 403.4k
  • 18
  • 501
  • 959
Tweeted twitter.com/StackMma/status/1072732925752459266
Source Link
Suite401
  • 5.1k
  • 10
  • 20

selective deletions from list

I have a list:

lis = {{"b","x","d"},{"a","z","b"},{"a","x","b"},{"a","x","c"},{"b","z","d"}} 

Certain consecutive elements of this list will have identical first and last members (in this example, "a" and "b" in lis[[2]] and lis[[3]]) and I would like to delete the element that has "x" as its middle element, to give:

res = {{"b","x","d"},{"a","z","b"},{"a","x","c"},{"b","z","d"}} 

It seems like a job for SequenceCases, but am having no luck.