The Set type allows the representation of an unordered set of values, with efficient insertion and lookup. Being represented internally as a hash table, membership can be tested in amortised O(1) time. As with arrays, insertion is non-destructive and requires that a copy of the set is made.
A set of values, with no duplicates or ordering. All values have the same type a.
Creates an empty set, with capacity as the initial capacity for the hash table. The capacity has no bearing on the semantics of the set, since it will be automatically expanded if it runs out of room.
The capacity of set. This has no bearing on the semantics of set, since it will be automatically expanded if it runs out of room. This shows the current size of the internal hash table.
Inserts a value into set, non-destructively. Returns a new, updated set. If value is already in set, this simply returns set unmodified.
Returns 1 if any element of set compares equal (according to eq) to item; 0 otherwise. This performs an efficient hash table lookup.
Convert array to a Set of the same elements. This discards duplicate elements.
Convert set to an Array of the same elements.
Note
The order of the elements in the resulting array is undefined. It should not be relied upon.
Determine whether xs and ys contain the same elements. This is preferred over eq, because it compares the set elements without regards to the order they were inserted. For example, array_to_set([8, 13]) may not equal array_to_set([13, 8]), but those sets will compare equal under this function.
Note that this uses eq to compare the set elements, so it will not correctly compare a set of sets.