Skip to main content
added 34 characters in body
Source Link
eldo
  • 83.2k
  • 6
  • 72
  • 202

Using Michael's data:

list = {{3, 5, 7, 5, 2}, {1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}};

Function definition

del[{e_, p_}][list_] /; list[[p]] == e := Nothing
del[_][list_] := list

ExamplesExpected results:

del[{3, 3}] /@ list

{{3, 5, 7, 5, 2}, {1, 3, 4, 5}}

del[{3, 1}] /@ list

{{1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}}

list = {{3, 5, 7, 5, 2}, {1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}};

Function definition

del[{e_, p_}][list_] /; list[[p]] == e := Nothing
del[_][list_] := list

Examples

del[{3, 3}] /@ list

{{3, 5, 7, 5, 2}, {1, 3, 4, 5}}

del[{3, 1}] /@ list

{{1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}}

Using Michael's data:

list = {{3, 5, 7, 5, 2}, {1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}};

Function definition

del[{e_, p_}][list_] /; list[[p]] == e := Nothing
del[_][list_] := list

Expected results:

del[{3, 3}] /@ list

{{3, 5, 7, 5, 2}, {1, 3, 4, 5}}

del[{3, 1}] /@ list

{{1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}}

Source Link
eldo
  • 83.2k
  • 6
  • 72
  • 202

list = {{3, 5, 7, 5, 2}, {1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}};

Function definition

del[{e_, p_}][list_] /; list[[p]] == e := Nothing
del[_][list_] := list

Examples

del[{3, 3}] /@ list

{{3, 5, 7, 5, 2}, {1, 3, 4, 5}}

del[{3, 1}] /@ list

{{1, 2, 3, 4, 5}, {1, 3, 4, 5}, {1, 3, 3}}