Skip to main content
Per Mr. Wizard's recommendation, added additional checks
Source Link
Bob Hanlon
  • 162.7k
  • 7
  • 81
  • 205

EDIT: Per Mr. Wizard's recommendation, added additional checks

del[data_del[data_List, position_Integer?Positive, val_] :=
 DeleteCases[data, _?(Length[#] >= position && #[[position]] == val &)]

SeedRandom[1];

data = RandomInteger[10, {5, 10}]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}, 
     {3, 5, 3, 0, 3, 2, 3, 9, 5, 1}, 
     {5, 2, 3, 9, 1, 0, 4, 4, 1, 5}}  *)

del[data, 3, 3]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}}
del[data_, position_Integer, val_] :=
 DeleteCases[data, _?(#[[position]] == val &)]

SeedRandom[1];

data = RandomInteger[10, {5, 10}]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}, 
     {3, 5, 3, 0, 3, 2, 3, 9, 5, 1}, 
     {5, 2, 3, 9, 1, 0, 4, 4, 1, 5}}  *)

del[data, 3, 3]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}}

EDIT: Per Mr. Wizard's recommendation, added additional checks

del[data_List, position_Integer?Positive, val_] :=
 DeleteCases[data, _?(Length[#] >= position && #[[position]] == val &)]

SeedRandom[1];

data = RandomInteger[10, {5, 10}]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}, 
     {3, 5, 3, 0, 3, 2, 3, 9, 5, 1}, 
     {5, 2, 3, 9, 1, 0, 4, 4, 1, 5}}  *)

del[data, 3, 3]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}}
Source Link
Bob Hanlon
  • 162.7k
  • 7
  • 81
  • 205

del[data_, position_Integer, val_] :=
 DeleteCases[data, _?(#[[position]] == val &)]

SeedRandom[1];

data = RandomInteger[10, {5, 10}]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}, 
     {3, 5, 3, 0, 3, 2, 3, 9, 5, 1}, 
     {5, 2, 3, 9, 1, 0, 4, 4, 1, 5}}  *)

del[data, 3, 3]

(*  {{1, 4, 0, 7, 0, 0, 8, 6, 0, 4}, 
     {1, 8, 5, 1, 1, 1, 3, 2, 10, 1}, 
     {6, 0, 2, 6, 4, 5, 4, 3, 0, 1}}