Reputation: 6811
Let's imagine a function bigset.containSubset(smallset)
which returns true/false
How should the result be for the following edge cases:
bigset
and smallset
are emptybigset
is nonEmpty and smallset
is emptyIf I define arbitrarily "if the intersection of both sets gives a result identical than the smaller set, then smallset
is a subset". Then the answer is true
for both cases above. Is this a correct assumption?
scala> Set().intersect(Set())
res1: scala.collection.immutable.Set[Nothing] = Set()
scala> Set(1,2,3).intersect(Set())
res2: scala.collection.immutable.Set[Int] = Set()
Upvotes: 0
Views: 748
Reputation: 66
As far as I learned it, the empty set is a subset of all sets. So if both sets are empty than they are the same set. If bigset is nonEmpty and smallset is empty, then smallset is a subset of bigset.
Upvotes: 5