lux/data/struct/dict

Types

Dict

A dictionary implemented as a Hash-Array Mapped Trie (HAMT).

(type: (Dict k v)
  {#hash (lux/control/hash;Hash k)
   #root (Node k v)})

Structs

(Eq<Dict> Eq<v>)

(All [a b] (-> (lux/control/eq;Eq b) (lux/control/eq;Eq (Dict a b))))

Values

(contains? key table)

(All [a b] (-> a (Dict a b) lux;Bool))

empty?

(All [a b] (-> (Dict a b) lux;Bool))

(entries dict)

(All [a b] (-> (Dict a b) (lux;List [a b])))

(from-list Hash<K> kvs)

(All [a b] (-> (lux/control/hash;Hash a) (lux;List [a b]) (Dict a b)))

(get key dict)

(All [a b] (-> a (Dict a b) (lux;Maybe b)))

(keys dict)

(All [a b] (-> (Dict a b) (lux;List a)))

(merge dict2 dict1)

Merges 2 dictionaries.

If any collisions with keys occur, the values of dict2 will overwrite those of dict1.

(All [a b] (-> (Dict a b) (Dict a b) (Dict a b)))

(merge-with f dict2 dict1)

Merges 2 dictionaries.

If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.

(All [a b] (-> (-> b b b) (Dict a b) (Dict a b) (Dict a b)))

(new Hash<K>)

(All [a b] (-> (lux/control/hash;Hash a) (Dict a b)))

(put key val dict)

(All [a b] (-> a b (Dict a b) (Dict a b)))

(put~ key val table)

Only puts the KV-pair if the key is not already present.

(All [a b] (-> a b (Dict a b) (Dict a b)))

(re-bind from-key to-key dict)

(All [a b] (-> a a (Dict a b) (Dict a b)))

(remove key dict)

(All [a b] (-> a (Dict a b) (Dict a b)))

(select keys dict)

Creates a sub-set of the given dict, with only the specified keys.

(All [a b] (-> (lux;List a) (Dict a b) (Dict a b)))

size

(All [a b] (-> (Dict a b) lux;Nat))

(update key f table)

Transforms the value located at key (if available), using the given function.

(All [a b] (-> a (-> b b) (Dict a b) (Dict a b)))

(values dict)

(All [a b] (-> (Dict a b) (lux;List b)))