import scala.collection.SortedSet
def main(args: Array[String]): Unit = {
val nums = List(1,3,2)
println(SortedSet(nums:_*))
}
TreeSet(1, 2, 3)
no problem
Probably not if you want to use something existing in stdlib. Sets are represented as explicit collections of items, not as predicates. You could however try to implement a set subclass that would work on predicates. Question is how you would implement the various methods existing on sets, including map, flatMap, groupBy, etc