Convenience functions for working with Set.
Apply a function that may succeed to all values in the set, but only keep the successes.
Set.fromList ["1", "2", "a", "3"]
|> Set.Extra.filterMap (String.toFloat >> Result.toMaybe)
--> Set.fromList [1, 2, 3]Check if a Set is a subset of another 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.
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]-- This module is used in the examples
import Set
Map a given function onto a set and union the resulting set.