2module Set (empty,singleton,insert,remove
13type Set t = Dict.Dict t ()
15-- Create an empty set.
19-- Create a set with one value.
20singleton : comparable -> Set comparable
21singleton k = Dict.singleton k ()
23-- Insert a value into a set.
24insert : comparable -> Set comparable -> Set comparable
25insert k = Dict.insert k ()
27-- Remove a value from a set. If the value is not found, no changes are made.
28remove : comparable -> Set comparable -> Set comparable
31-- Determine if a value is in a set.
32member : comparable -> Set comparable -> Bool
35-- Get the union of two sets. Keep all values.
36union : Set comparable -> Set comparable -> Set comparable
39-- Get the intersection of two sets. Keeps values that appear in both sets.
40intersect : Set comparable -> Set comparable -> Set comparable
41intersect = Dict.intersect
43-- Get the difference between the first set and the second. Keeps values
44-- that do not appear in the second set.
45diff : Set comparable -> Set comparable -> Set comparable
48-- Convert a set into a list.
49toList : Set comparable -> [comparable]
52-- Convert a list into a set, removing any duplicates.
53fromList : [comparable] -> Set comparable
54fromList xs = List.foldl insert empty xs
56-- Fold over the values in a set, in order from lowest to highest.
57foldl : (comparable -> b -> b) -> b -> Set comparable -> b
58foldl f b s = Dict.foldl (\k _ b -> f k b) b s
60-- Fold over the values in a set, in order from highest to lowest.
61foldr : (comparable -> b -> b) -> b -> Set comparable -> b
62foldr f b s = Dict.foldr (\k _ b -> f k b) b s
64-- Map a function onto a set, creating a new set with no duplicates.
65map : (comparable -> comparable') -> Set comparable -> Set comparable'
66map 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