ContainsAll[list1,list2]
yields True if list1 contains all of the elements of list2.
ContainsAll[list2]
is an operator form that yields True when the object to which it is applied contains all of the elements of list2.
ContainsAll
ContainsAll[list1,list2]
yields True if list1 contains all of the elements of list2.
ContainsAll[list2]
is an operator form that yields True when the object to which it is applied contains all of the elements of list2.
Details and Options
- In ContainsAll[list1,list2], the listi must be lists of expressions, or representations of them, namely objects with heads like SparseArray, QuantityArray, Association or EntityClass.
- ContainsAll[list1,list2,SameTesttest] applies test to each pair of elements in the listi to determine whether they should be considered the same.
- ContainsAll[list2][list1] is equivalent to ContainsAll[list1,list2].
Examples
open all close allBasic Examples (2)
Scope (4)
The English word facetious contains all five vowels:
ContainsAll[Characters["facetious"], {"a", "e", "i", "o", "u"}]Use ContainsAll in operator form:
all5 = ContainsAll[{1, 2, 3, 4, 5}]all5[{2, 3, 1, 3}]all5[{4, 2, 3, 1, 6, 1, 5}]Find the movies whose cast contains both Angelina Jolie and Brad Pitt:
EntityList[EntityClass["Movie", "Cast" -> ContainsAll[{Entity["Person", "AngelinaJolie::8cggf"], Entity["Person", "BradPitt::6xy46"]}]]]ContainsAll works with associations:
ContainsAll[<|a -> x, b -> y, c -> z, d -> x|>, {x, y, z}]ContainsAll[<|a -> x, b -> y, c -> z, d -> x|>, <|1 -> x, 2 -> y, 3 -> z|>]Options (2)
SameTest (2)
By default, ContainsAll considers elements to be the same if they are identical:
list = Subdivide[Quantity[0, "Meters"], Quantity[1, "Meters"], 10]ContainsAll[list, {Quantity[1/5, "Meters"], Quantity[1/2, "Meters"]}]Changes of units are taken into account, as long as they represent the exact same quantity:
ContainsAll[list, {Quantity[20, "Centimeters"], Quantity[50, "Centimeters"]}]Numerical approximations are not considered as the same object:
ContainsAll[list, {Quantity[20., "Centimeters"], Quantity[50., "Centimeters"]}]Use Equal as the comparison function to have numerical tolerance:
ContainsAll[list, {Quantity[20., "Centimeters"], Quantity[50., "Centimeters"]}, SameTest -> Equal]String comparisons are case sensitive by default:
ContainsAll[{"A", "B", "C"}, {"a", "b"}]Convert to lower case before comparing:
ContainsAll[{"A", "B", "C"}, {"a", "b"}, SameTest -> (SameQ[ToLowerCase[#1], ToLowerCase[#2]]&)]Applications (4)
Randomly find 10 English words containing all five vowels:
Select[RandomSample@DictionaryLookup[], ContainsAll[Characters[#], {"a", "e", "i", "o", "u"}]&, 10]Find the shortest French word containing all five vowels:
MinimalBy[Select[WordList[Language -> "French"], ContainsAll[Characters[#], {"a", "e", "i", "o", "u"}]&], StringLength]Take the first character of each word of a text:
firstchars = StringTake[#, 1]& /@ ExampleData[{"Text", "ToBeOrNotToBe"}, "Words"]It does not contain words starting with all letters of the alphabet:
ContainsAll[ToLowerCase[firstchars], CharacterRange["a", "z"]]Complement[CharacterRange["a", "z"], ToLowerCase[firstchars]]This larger text does contain words starting with all letters of the alphabet:
Length[firstchars = StringTake[#, 1]& /@ ExampleData[{"Text", "OriginOfSpecies"}, "Words"]]ContainsAll[firstchars, CharacterRange["a", "z"]]All of them do not appear as capital first letters in the text:
ContainsAll[firstchars, CharacterRange["A", "Z"]]A pangrammatic lipogram is a text that uses all letters of the alphabet except one:
pangrammaticLipogramQ[text_, letter_] := ContainsAll[Characters[text], Complement[Alphabet[], {letter}]]pangrammaticLipogramQ["a jovial swain should not complain of any buxom fair who mocks his pain and thinks it gain to quiz his awkward air", "e"]Properties & Relations (3)
ContainsAll[list1,list2] is equivalent to SubsetQ[list1,list2]:
list1 = {5, 1, 0, 0, 0, 0, 4, 5, 0, 0};list2 = {1, 2, 3, 4, 5};{ContainsAll[list1, list2], SubsetQ[list1, list2]}Reversing the arguments of ContainsAll is equivalent to using ContainsOnly:
list1 = {3, 1, 0, 0, 4, 0, 3, 2, 4, 0};list2 = {1, 2, 3, 4, 5};{ContainsAll[list1, list2], ContainsOnly[list2, list1]}ContainsAll[list,{}] always returns True:
ContainsAll[{1, 2}, {}]ContainsAll[{}, {}]See Also
SubsetQ ContainsNone ContainsAny ContainsExactly ContainsOnly MemberQ FreeQ Intersection Complement
Function Repository: StringContainsAll MaximalSubsets
Related Guides
History
Text
Wolfram Research (2015), ContainsAll, Wolfram Language function, https://reference.wolfram.com/language/ref/ContainsAll.html.
CMS
Wolfram Language. 2015. "ContainsAll." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ContainsAll.html.
APA
Wolfram Language. (2015). ContainsAll. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ContainsAll.html
BibTeX
@misc{reference.wolfram_2026_containsall, author="Wolfram Research", title="{ContainsAll}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/ContainsAll.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_containsall, organization={Wolfram Research}, title={ContainsAll}, year={2015}, url={https://reference.wolfram.com/language/ref/ContainsAll.html}, note=[Accessed: 13-June-2026]}