# Remove terms from the list [closed]

I have the following list:

l = {{-5, -5, -5}, {-7, -5, -1}, {-9, -3, 15}, {-11, 1, 49}, {-13, 7, 0},
{-15, 15, 0}, {-17, 25, 0}, {-19, 37, 0}, {-21, 51, 0}, {-23, 67, 0}, {-25, 85, 0}}


I need to remove the items in the list that contain zero in the third item value. Finally I wish to obtain the following list:

{{-5, -5, -5}, {-7, -5, -1}, {-9, -3, 15}, {-11, 1, 49}}

l = {{-5, -5, -5}, {-7, -5, -1}, {-9, -3, 15}, {-11, 1, 49}, {-13, 7,
0}, {-15, 15, 0}, {-17, 25, 0}, {-19, 37, 0}, {-21, 51, 0}, {-23,
67, 0}, {-25, 85, 0}};

DeleteCases[l, {a_, b_, c_} /; c == 0]

• Simpler is DeleteCases[l, {_, _, 0}] Apr 19, 2018 at 2:05
• It depends if you want to check for exact zeroes (0) only or if you want to catch machine precision zeroes as well (0.) Apr 19, 2018 at 8:47
• Or with Cases[l, {a_, b_, c_} /; c != 0] Apr 19, 2018 at 11:08
Select[l, #[[3]] != 0 &]


{{-5, -5, -5}, {-7, -5, -1}, {-9, -3, 15}, {-11, 1, 49}}

this should be quite fast:

Pick[l, Unitize@l[[All, -1]], 1]

(* {{-5, -5, -5}, {-7, -5, -1}, {-9, -3, 15}, {-11, 1, 49}} *)