issubset

..  issubset(A, S) -> Bool
             ⊆(A,S) -> Bool

Return ``true`` if ``A`` is a subset of or equal to ``S``.

Examples

Check if every element of a is in b:

julia> issubset([1, 2, 3], [1, 2, 3, 4, 5])
true

This example checks if every element in [1, 2, 3] is present in [1, 2, 3, 4, 5]. Since all elements are present, it returns true.

julia> issubset([4, 5, 6], [1, 2, 3])
false

In this case, not all elements in [4, 5, 6] are present in [1, 2, 3], so it returns false.

Check if a is a proper subset of b:

julia> issubset([1, 2], [1, 2, 3])
true

Here, [1, 2] is a proper subset of [1, 2, 3], so it returns true.

julia> issubset([1, 2, 3], [1, 2, 3])
false

Since [1, 2, 3] is not a proper subset of itself, it returns false.

Check if a is not a subset of b:

julia> issubset([4, 5, 6], [1, 2, 3])
true

In this example, [4, 5, 6] is not a subset of [1, 2, 3], so it returns true.

julia> issubset([1, 2, 3], [1, 2, 3])
false

Since [1, 2, 3] is a subset of itself, it returns false.

Common mistake example:

julia> issubset([1, 2, 3], 4)
ERROR: MethodError: no method matching issubset(::Array{Int64,1}, ::Int64)

In this example, the second argument provided is not an iterable collection. The issubset function expects both arguments to be collections that can be iterated over. Make sure to provide valid collections as arguments to issubset.

See Also

complement, complement!, intersect, intersect!, issubset, selectperm, selectperm!, Set, setdiff, setdiff!, symdiff, union, union!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: