You can use Java HashSet as follows:
>> x = java.util.HashSet; >> x.add(1); >> x.add(2); >> x.contains(1) ans = 1 >> x.contains(3) ans = 0 >> x x = [2.0, 1.0]
The comments stated that the HashSet is not streamlined. Which is absolutely true. To blame! Instead, you can use TreeSet, which is ordered:
>> x = java.util.TreeSet; >> x.add(1); >> x.add(3); >> x.add(2); >> x x = [1.0, 2.0, 3.0]
source share