AssocList
Lists of key-value entries ("associations").
Implements the same operations as library Trie
, but uses a
linked-list of entries and no hashing.
AssocList
type AssocList<K, V> = List.List<(K, V)>
polymorphic association linked lists between keys and values
find
func find<K, V>(al : AssocList<K, V>, k : K, k_eq : (K, K) -> Bool) : ?V
Find the value associated with a given key, or null if absent.
disj
This operation generalizes the notion of "set union" to finite maps. Produces a "disjunctive image" of the two lists, where the values of matching keys are combined with the given binary operator.
For unmatched entries, the operator is still applied to create the value in the image. To accomodate these various situations, the operator accepts optional values, but is never applied to (null, null).
join
This operation generalizes the notion of "set intersection" to finite maps. Produces a "conjuctive image" of the two lists, where the values of matching keys are combined with the given binary operator, and unmatched entries are not present in the output.
fold
func fold<K, V, X>(al : AssocList<K, V>, nil : X, cons : (K, V, X) -> X) : X
Fold the entries based on the recursive list structure.