A membership test determines whether a specified element belongs to a collection. In Julia, use `in` or its Greek equivalent `∈`; use `⊆` or `issubset` for multiple elements. section 13.2.1
Choose the collection with the test’s needs in mind. Sets provide fast membership checks and fast insertion or removal, while arrays preserve order and support indexed access. For small collections, arrays may be faster; above roughly 30–40 elements, sets outperform unsorted arrays for membership tests. section 13.2.1
Testing one or several elements
julia> A = [2, 7, 9, 10, 11, 12, 15, 18, 19] julia> S = Set(A) julia> 18 in S true julia> 18 ∈ A true julia> [11, 15] ⊆ A true julia> issubset([11, 15], S) true section 13.2.1
Table 13.1 Differences and similarities between sets and arrays (view table figure)
Compare sets and arrays by ordering, duplicates, random access, iteration, and membership-test speed. section 13.2.1
