DeleteElements
DeleteElements[list,{e1,e2,…}]
removes all instances of elements ei from list.
DeleteElements[list,n{e1,e2,…}]
removes up to n instances of each ei from list.
DeleteElements[list,{n1,n2,…}{e1,e2,…}]
removes up to ni instances of ei from list.
Details
- The object list can have any head, not necessarily List.
- DeleteElements[list,{n1,n2}{e,e}] removes up to n1+n2 instances of e from list.
- DeleteElements[list,{e1,e2,…}] is equivalent to DeleteElements[list,Infinity{e1,e2,…}].
Examples
open allclose allBasic Examples (3)
Properties & Relations (5)
DeleteElements[list,elems] is equivalent to DeleteElements[list,Infinityelems]:
Remove one instance of b and then remove two other instances of b:
DeleteElements[list,elems] is equivalent to DeleteCases[list,Alternatives@@elems]:
DeleteElements[list,elems] removes elements from list, preserving the order and multiplicity of the other elements:
Complement[list,elems] does not preserve the order and multiplicity of the other elements:
SubsetReplace provides an alternative way of deleting a number of copies of an element from a list:
Text
Wolfram Research (2022), DeleteElements, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteElements.html.
CMS
Wolfram Language. 2022. "DeleteElements." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DeleteElements.html.
APA
Wolfram Language. (2022). DeleteElements. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteElements.html