I\'m having an unsorted list and want to know, whether all items in it are unique. My naive approach would be
val l = List(1,2,3,4,3) def isUniqueList(l: List[Int
A more efficient method would be to attempt to find a dupe; this would return more quickly if one were found:
var dupes : Set[A] = Set.empty def isDupe(a : A) = if (dupes(a)) true else { dupes += a; false } //then l exists isDupe