ContainsNone[list1,list2]
yields True if list1 contains none of the elements in list2.
ContainsNone[list2]
is an operator form that yields True when the object to which it is applied contains none of the elements of list2.
ContainsNone
ContainsNone[list1,list2]
yields True if list1 contains none of the elements in list2.
ContainsNone[list2]
is an operator form that yields True when the object to which it is applied contains none of the elements of list2.
Details and Options
- In ContainsNone[list1,list2], the listi must be lists of expressions, or representations of them, namely objects with heads like SparseArray, QuantityArray, Association or EntityClass.
- ContainsNone[list1,list2,SameTesttest] applies test to each pair of elements in the listi to determine whether they should be considered the same.
- ContainsNone[list2][list1] is equivalent to ContainsNone[list1,list2].
Examples
open all close allBasic Examples (2)
Scope (5)
There are English words containing none of the five vowels:
ContainsNone[Characters["rhythm"], {"a", "e", "i", "o", "u"}]Use ContainsNone in operator form:
noweekend = ContainsNone[{Saturday, Sunday}]noweekend[{Monday, Thursday, Tuesday}]noweekend[{Monday, Saturday, Tuesday}]EntityList[EntityClass["MusicWork", {"FirstReleaseDate" -> DateObject[{1950}, "Year", "Gregorian", -6.], "Composers" -> ContainsNone[{Entity["Person", "NatKingCole::5czsz"], Entity["Person", "ColePorter::44j37"]}]}]]Find the movies directed by Pedro Almodóvar whose cast includes none of several actors:
EntityList[EntityClass["Movie", {"Director" -> Entity["Person", "PedroAlmodovar::8n5q5"], "Cast" -> ContainsNone[{Entity["Person", "AntonioBanderas::2tm43"], Entity["Person", "PenelopeCruz::92q5z"]}]}]]ContainsNone works with associations:
ContainsNone[<|a -> x, b -> y, c -> z|>, {r, t}]ContainsNone[<|a -> x, b -> y, c -> z|>, <|1 -> r, 2 -> t|>]Options (2)
SameTest (2)
By default, ContainsNone considers elements to be the same if they are identical:
list = Subdivide[Quantity[0, "Meters"], Quantity[6, "Meters"], 3]ContainsNone[list, {Quantity[1, "Meters"], Quantity[2, "Meters"]}]Changes of units are taken into account, as long as they represent the exact same quantity:
ContainsNone[list, {Quantity[100, "Centimeters"], Quantity[200, "Centimeters"]}]Numerical approximations are not considered as the same object:
ContainsNone[list, {Quantity[100., "Centimeters"], Quantity[200., "Centimeters"]}]Use Equal as the comparison function to have numerical tolerance:
ContainsNone[list, {Quantity[100., "Centimeters"], Quantity[200., "Centimeters"]}, SameTest -> Equal]String comparisons are case sensitive by default:
ContainsNone[{"A", "B", "C"}, {"a", "b"}]Convert to lower case before comparing:
ContainsNone[{"A", "B", "C"}, {"a", "b"}, SameTest -> (SameQ[ToLowerCase[#1], ToLowerCase[#2]]&)]Applications (2)
Take the list of words in this text:
Length[words = ExampleData[{"Text", "AliceInWonderland"}, "Words"]]That list of words does not contain any of these:
ContainsNone[ToLowerCase[words], {"bird", "fish", "flower"}]However, that is not true if "rabbit" is added:
ContainsNone[ToLowerCase[words], {"rabbit", "bird", "fish", "flower"}]A lipogram is a text that does not use a given letter:
lipogramQ[text_, letter_] := ContainsNone[Characters[text], {letter}]Find the longest English word that does not contain the letter e:
MaximalBy[Select[DictionaryLookup[], lipogramQ[#, "e"]&], StringLength]Properties & Relations (5)
ContainsNone[list1,list2] is equivalent to testing for empty intersection of the lists:
list1 = {6, 7, 2, 8, 1};list2 = {4, 9, 3, 10, 4};{ContainsNone[list1, list2], Intersection[list2, list1] === {}}ContainsNone[list1,list2] is equivalent to DisjointQ[list1,list2]:
list1 = {7, 6, 10, 8, 0};list2 = {0, 7, 0, 2, 1};{ContainsNone[list1, list2], DisjointQ[list2, list1]}ContainsNone is a symmetric function of its arguments. That is, ContainsNone[list1,list2]==ContainsNone[list2,list1]:
list1 = {6, 0, 10, 8, 8};list2 = {5, 9, 2, 7, 7};{ContainsNone[list1, list2], ContainsNone[list2, list1]}Negation of ContainsNone[list1,list2] is equivalent to ContainsAny[list1,list2]:
list1 = {6, 5, 10, 8, 4};list2 = {7, 1, 10, 0, 2};{Not[ContainsNone[list1, list2]], ContainsAny[list1, list2]}ContainsNone[list,{}] always returns True:
ContainsNone[{1, 2}, {}]ContainsNone[{}, {}]Related Guides
History
Text
Wolfram Research (2015), ContainsNone, Wolfram Language function, https://reference.wolfram.com/language/ref/ContainsNone.html.
CMS
Wolfram Language. 2015. "ContainsNone." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ContainsNone.html.
APA
Wolfram Language. (2015). ContainsNone. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ContainsNone.html
BibTeX
@misc{reference.wolfram_2026_containsnone, author="Wolfram Research", title="{ContainsNone}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/ContainsNone.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_containsnone, organization={Wolfram Research}, title={ContainsNone}, year={2015}, url={https://reference.wolfram.com/language/ref/ContainsNone.html}, note=[Accessed: 12-June-2026]}