A set of values unique according to a comparison function. Values can be any type.
A comparison function a -> a -> Order is used to compare values, this should uniquely identify values.
Insert, remove, and query operations all take O(log n) time.
Remove a value from a set. If the value is not found, no changes are made.
Get the intersection of two sets. Keeps values that appear in both sets.
Get the difference between the first set and the second. Keeps values that do not appear in the second set.
Map a function onto a set, creating a new set with no duplicates.
Fold over the values in a set, in order from lowest to highest.
Fold over the values in a set, in order from highest to lowest.
Only keep elements that pass the given test.
import SetAny as Set exposing (Set)
numbers : Set Int
numbers =
[ -2, -1, 0, 1, 2 ] |> Set.fromList compare
positives : Set Int
positives =
numbers |> Set.filter compare (\x -> x > 0)
positives --> [1,2] |> Set.fromList compare
Represents a set of unique values. So
(Set Int)is a set of integers and(Set String)is a set of strings.