A set of unique values. The values can be any comparable type.
This includes Int, Float, Time, Char, String, and tuples or lists of comparable types.
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.
Determine if two sets are equal. This is needed because the structure could be different depending on insertion order.
Get the union of two sets. Keep all values.
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.
Gets the smallest value.
[ 1, 2 ]
|> fromList
|> getMin
--> Just 1
empty
|> getMin
--> NothingGets the biggest value.
[ 1, 2 ]
|> fromList
|> getMax
--> Just 2
empty
|> getMax
--> NothingRemoves the smallest value from the set, and returns it.
[ 1, 2 ]
|> fromList
|> popMin
--> Just ( 1, fromList [ 2 ] )
empty
|> popMin
--> NothingRemoves the biggest value from the set, and returns it.
[ 1, 2 ]
|> fromList
|> popMax
--> Just ( 2, fromList [ 1 ] )
empty
|> popMax
--> NothingApply a function to all values in a set.
Keep only the values that pass the given test.
Partition a set according to some test. The first set contains all values which passed the test, and the second contains the pairs that did not.
Convert the set from an equivalent one from elm/core.
A foldl that can stop early instead of traversing the whole set.
stoppableFoldl
(\v acc ->
if v >= 10 then
Stop acc
else
Continue (v + acc)
)
0
(fromList <| List.range 1 10000)
--> 55A foldr that can stop early instead of traversing the whole set.
stoppableFoldr
(\v acc ->
if v <= 9990 then
Stop acc
else
Continue (v + acc)
)
0
(fromList <| List.range 1 10000)
--> 89964
Represents a set of unique values. So
(Set Int)is a set of integers and(Set String)is a set of strings.