2module Set (empty,singleton,insert,remove
14-- Create an empty set.
15empty : Set (Comparable k)
18-- Create a set with one value.
19singleton : Comparable k -> Set (Comparable k)
20singleton k = Dict.singleton k ()
22-- Insert a value into a set.
23insert : Comparable k -> Set (Comparable k) -> Set (Comparable k)
24insert k = Dict.insert k ()
26-- Remove a value from a set. If the value is not found, no changes are made.
27remove : Comparable k -> Set (Comparable k) -> Set (Comparable k)
30-- Determine if a value is in a set.
31member : Comparable k -> Set (Comparable k) -> Bool
34-- Get the union of two sets. Keep all values.
35union : Set (Comparable k) -> Set (Comparable k) -> Set (Comparable k)
38-- Get the intersection of two sets. Keeps values that appear in both sets.
39intersect : Set (Comparable k) -> Set (Comparable k) -> Set (Comparable k)
40intersect = Dict.intersect
42-- Get the difference between the first set and the second. Keeps values
43-- that do not appear in the second set.
44diff : Set (Comparable k) -> Set (Comparable k) -> Set (Comparable k)
47-- Convert a set into a list.
48toList : Set (Comparable k) -> [Comparable k]
51-- Convert a list into a set, removing any duplicates.
52fromList : [Comparable k] -> Set (Comparable k)
53fromList xs = List.foldl insert empty xs
55-- Fold over the values in a set, in order from lowest to highest.
56foldl : (Comparable a -> b -> b) -> b -> Set (Comparable a) -> b
57foldl f b s = Dict.foldl (\k _ b -> f k b) b s
59-- Fold over the values in a set, in order from highest to lowest.
60foldr : (Comparable a -> b -> b) -> b -> Set (Comparable a) -> b
61foldr f b s = Dict.foldr (\k _ b -> f k b) b s
63-- Map a function onto a set, creating a new set with no duplicates.
64map : (Comparable a -> Comparable b) -> Set (Comparable a) -> Set (Comparable b)
65map 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