ContainsOnly
ContainsOnly[e1,e2]
yields True if e1 contains only elements that appear in e2.
ContainsOnly[e2]
is an operator form that yields True when the object to which it is applied contains only elements that appear in e2.
Examples
open allclose allBasic Examples (2)
Scope (4)
This is one of the longest English words containing only vowels:
Use ContainsOnly in operator form:
The number of songs composed either by John Lennon or Paul McCartney, or by both together:
ContainsOnly works with associations:
Options (2)
SameTest (2)
By default, ContainsOnly considers elements to be the same if they are identical:
Changes of units are taken into account, as long as they represent the exact same quantity:
Numerical approximations are not considered as the same object:
Use Equal as the comparison function to have numerical tolerance:
Applications (1)
Properties & Relations (3)
Reversing the arguments of ContainsOnly is equivalent to using ContainsAll:
ContainsOnly[list1,list2] is equivalent to SubsetQ[list2,list1]:
ContainsOnly[{},list] always returns True:
Text
Wolfram Research (2015), ContainsOnly, Wolfram Language function, https://reference.wolfram.com/language/ref/ContainsOnly.html.
CMS
Wolfram Language. 2015. "ContainsOnly." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ContainsOnly.html.
APA
Wolfram Language. (2015). ContainsOnly. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ContainsOnly.html