Convenience functions for working with Set.
Apply a function that may succeed to all values in the set, but only keep the successes.
import Set exposing (Set)
Set.fromList ["1", "2", "a", "3"]
|> Set.Extra.filterMap String.toFloat
--> Set.fromList [1, 2, 3]Check if a Set is a subset of another Set.
import Set exposing (Set)
Set.Extra.subset
(Set.fromList [1,2,3])
(Set.fromList [1,2,3,4,5])
--> TrueIf the set does not contain the element, add it. If it does contain the element, remove it.
import Set exposing (Set)
Set.Extra.toggle 1 (Set.fromList [1,2,3])
--> Set.fromList [2, 3]
Set.Extra.toggle 1 (Set.fromList [2,3])
--> Set.fromList [1, 2, 3]
Map a given function onto a set and union the resulting set.