Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • $\begingroup$ Generalization: how would this work with a slightly different data set, where the marker for deletion isn't the last member of the list element: say, lis =lis = {{"a", "b", "c", "z"}, {"d", "e", "f", "z"}, {"d", "e", "x", "z"}, {"g", "h", "i", "z"}, {"w", "x", "y", "z"}, {"w", "x", "x", "z"}} $\endgroup$ Commented Sep 19, 2021 at 3:33
  • $\begingroup$ please ignore the above comment, the comment edit timed out before I finished my question.. Here is the correct comment: Generalization : how would this work with a slightly different data set, where the \ marker for deletion isn' t the last member of the list element : say, {{"a", "b", "c", "z"}, {"d", "e", "f", "z"}, {"d", "e", "x", "z"}, {"g", "h", "i", "z"}, {"q", "r", "s", "t"}, {"q", "r", "x", "t"}} with the desired res to be : {{"a", "b", "c", "z"}, {"d", "e", "f", "z"}, {"g", "h", "i", "z"}, {"q", "r", "s", "t"}} $\endgroup$ Commented Sep 19, 2021 at 3:44
  • $\begingroup$ @Suite401, maybe something like: ClearAll[f]; f[p_] := DeleteDuplicates[SortBy[#[[p]] == "x" &]@#, Drop[#, {p}] == Drop[#2, {p}] && MemberQ[{##}[[All, p]], "x"] &] &; f[3]@lis2? $\endgroup$ Commented Sep 19, 2021 at 3:53
  • $\begingroup$ OK will give it a try. $\endgroup$ Commented Sep 19, 2021 at 3:56