2module Set (empty,singleton,insert,remove
14-- Create an empty set.
18-- Create a set with one value.
20singleton k = Dict.singleton k ()
22-- Insert a value into a set.
23insert : t -> Set t -> Set t
24insert k = Dict.insert k ()
26-- Remove a value from a set. If the value is not found, no changes are made.
27remove : t -> Set t -> Set t
30-- Determine if a value is in a set.
31member : t -> Set t -> Bool
34-- Get the union of two sets. Keep all values.
35union : Set t -> Set t -> Set t
38-- Get the intersection of two sets. Keeps values that appear in both sets.
39intersect : Set t -> Set t -> Set t
40intersect = Dict.intersect
42-- Get the difference between the first set and the second. Keeps values that do not appear in the second set.
43diff : Set t -> Set t -> Set t
46-- Convert a set into a list.
50-- Convert a list into a set, removing any duplicates.
51fromList : [t] -> Set t
52fromList xs = List.foldl (\k t -> Dict.insert k () t) empty xs
54-- Fold over the values in a set, in order from lowest to highest.
55foldl : (a -> b -> b) -> b -> Set a -> b
56foldl f b s = Dict.foldl (\k _ b -> f k b) b s
58-- Fold over the values in a set, in order from highest to lowest.
59foldr : (a -> b -> b) -> b -> Set a -> b
60foldr f b s = Dict.foldr (\k _ b -> f k b) b s
62-- Map a function onto a set, creating a new set with no duplicates.
63map : (a -> b) -> Set a -> Set b
64map f s = fromList (List.map f (toList s))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list