A Dict over any keys with a mapping to comparable.
Dictionary over any keys with a function to map keys to comparable.
empty : (k -> comparable) -> Dict comparable k v
Create an empty dictionary by suppling function used for comparing keys.
singleton : (k -> comparable) -> k -> v -> Dict comparable k v
Create a dictionary with one key-value pair.
insert : k -> v -> Dict comparable k v -> Dict comparable k v
Insert a key-value pair into a dict. Replaces value when there is a collision.
update : k -> (Maybe v -> Maybe v) -> Dict comparable k v -> Dict comparable k v
Update the value of a dict for a specific key with a given function.
remove : k -> Dict comparable k v -> Dict comparable k v
Remove a key-value pair from a dict. If the key is not found, no changes are made.
isEmpty : Dict comparable k v -> Basics.Bool
Determine if a dict is empty.
`isEmpty empty == True`
member : k -> Dict comparable k v -> Basics.Bool
Determine if a whole key is in a dict.
get : k -> Dict comparable k v -> Maybe v
Get the value associated with a key. If the key is not found, return
Nothing
.
size : Dict comparable k v -> Basics.Int
Determine the number of key-value pairs in the dict.
keys : Dict comparable k v -> List k
Get all of the keys in a dict, sorted from lowest to highest.
values : Dict comparable k v -> List v
Get all of the values in a dict, in the order of their keys.
toList : Dict comparable k v -> List ( k, v )
Convert a dict into an association list of key-value pairs, sorted by keys.
fromList : (k -> comparable) -> List ( k, v ) -> Dict comparable k v
Convert an association list into a dict.
map : (k -> a -> b) -> Dict comparable k a -> Dict comparable k b
Apply a function to all values in a dict.
foldl : (k -> v -> b -> b) -> b -> Dict comparable k v -> b
Fold over the key-value pairs in a dict from lowest key to highest key.
foldr : (k -> v -> b -> b) -> b -> Dict comparable k v -> b
Fold over the key-value pairs in a dict from highest key to lowest key.
filter : (k -> v -> Basics.Bool) -> Dict comparable k v -> Dict comparable k v
Keep only the key-value pairs that pass the given test.
partition : (k -> v -> Basics.Bool) -> Dict comparable k v -> ( Dict comparable k v, Dict comparable k v )
Partition a dict according to some test. The first dict contains all key-value pairs which passed the test, and the second contains the pairs that did not.
union : Dict comparable k v -> Dict comparable k v -> Dict comparable k v
Combine two dicts. If there is a collision, preference is given to the first dict.
intersect : Dict comparable k v -> Dict comparable k v -> Dict comparable k v
Keep a key-value pair when its key appears in the second dict. Preference is given to values in the first dictionary.
diff : Dict comparable k v -> Dict comparable k v -> Dict comparable k v
Keep a key-value pair when its key does not appear in the second dict.
merge : (k -> a -> result -> result) -> (k -> a -> b -> result -> result) -> (k -> b -> result -> result) -> Dict comparable k a -> Dict comparable k b -> result -> result
The most general way of combining two dicts. You provide three accumulators for when a given key appears:
You then traverse all the keys from lowest to highest, building up whatever you want.