Returns a new list containing a single occurrence of each duplicated item in the original list . The order of the items in the returned list is not defined. Non-duplicated items also appear in the returned list . There is no way to specify which occurrences of the duplicates are removed.
RemoveDuplicates ( list As List, _ Optional key As Name = :Identity, _ Optional test As Name = :Equal ) As List
Argument | Type | Description |
---|---|---|
list | List | The list from which to remove duplicates. |
key | Name | Optional; name of a function to be applied to each item when getting its value during then check for duplicates; default is :Identity. |
test | Name | Optional; name of a function to be applied to each item when comparing two values; default is :Equal. |
Intent >RemoveDuplicates({4, 7, 4, 2, 6, 6, 3, 1, 3}) --> {4, 7, 2, 6, 3, 1}
Intent >RemoveDuplicates({:a, :z, :c, :a, 3, :e, :f, :g, :c}) --> {:a, :z, :c, 3, :e, :f, :g}
Intent >RemoveDuplicates({:a, :b, 3, "a", "b", {3}, "3"}, test := :sameType?) --> {:a, 3, "a", {3}}
Function sameType?(I as Any, j as Any) as Boolean sameType? = (typeName(i) = typeName(j)) End Function
Intent >RemoveDuplicates({1.4, 2.5, 2.6, 3.5, 1.1, 2.3}, key := :ceiling) --> {1.4, 2.5, 3.5}Result is not necessarily in this order and not necessarily the exact elements. For example, instead of 2.5, 2.6 or 2.3 may be in the list .
Intent >RemoveDuplicates({{4.5,6},{2.5,6},{1.5,8},{4.5,6}}) --> {{4.5, 6}, {2.5, 6}, {1.5, 8}}