SE-0207: Add a containsOnly algorithm to Sequence

I did a survey of naming conventions across a variety of languages:

Language Predicate true for at least one Predicate true for all At least one equals given value All elements equal given value
C# Any All Contains
C++ any_of all_of
Clojure some every?
F# exists forall contains
Haskell any all elem
Java anyMatch allMatch contains
JavaScript some every includes
Kotlin any all contains
Matlab any all ismember
PHP array_some array_every in_array
Python any all in
R any all %in% all.equal
Ruby any? all? include?
Rust any all contains
Scala exists forall contains

This includes nearly all the most popular & “most loved” languages in the latest Stack Overflow survey that have closures or other predicate-like constructs.

Some observations:

  • For the first function:
    • 10 use the word “any”
    • 3 use “some”
    • 2 use “exists”
  • For the second function:
    • 12 use the word “all”
    • 3 use the word “every”
  • For the third function:
    • 6 use the word “contains”
    • 3 use “in”
    • 2 use “include(s)”
    • 1 uses “elem”
  • No language strives for parallel naming between the first and third.
  • Only one language implements an “all elements equal a given value” function — at least that I could find. If any of these other languages have one and I missed it, please let me know and I'll update the table. (Rust does have an all_equal, but it seems to mean all equal to each other, not to a given value)