No matching definitions.

tur/map

stdlib/map.tur

typed Map[K V]: persistent hash map requiring Hash[K] and Eq[K].

Since: Phase TM0

defstruct

Map

(defstruct Map [K V])

parameterized persistent map with key type K and value type V.

Since: Phase TM0

defn

map-new

(map-new)

create a new empty typed map.

An empty Map[K V].

(map-new)  ; => empty Map

Since: Phase TM0

defn

map-hamt

(map-hamt [m :int])

internal accessor for the HAMT backing store.

defn

map-wrap

(map-wrap [h :ptr<void>])

internal constructor from a HAMT pointer.

defn

map-assoc

(map-assoc [m :int key :int val :int])

insert or update a key/value pair; returns a new map.

msource Map[K V]
keykey of type K (used as hash for scalar keys)
valvalue of type V

A new Map[K V] with the entry inserted or updated.

(map-assoc my-map 1 100)  ; => updated map

Since: Phase TM0

defn

map-assoc-h

(map-assoc-h [m :int h :int key :int val :int])

insert or update with an explicit hash; returns a new map.

msource Map[K V]
hprecomputed hash of key (from Hash[K] typeclass)
keykey of type K
valvalue of type V

A new Map[K V] with the entry inserted or updated.

(map-assoc-h my-map (hash k) k v)  ; => updated map

Since: Phase TM0

defn

map-dissoc

(map-dissoc [m :int h :int key :int])

remove a key from the map; returns a new map.

msource Map[K V]
hprecomputed hash of key
keykey of type K

A new Map[K V] with the key removed.

(map-dissoc my-map (hash k) k)  ; => map without k

Since: Phase TM0

defn

map-get

(map-get [m :int h :int key :int])

look up a key; returns the value or 0 if absent.

mMap[K V]
hprecomputed hash of key
keykey of type K

The value for the key, or 0 (none) if absent.

(map-get my-map (hash k) k)  ; => value or 0

Since: Phase TM0

defn

map-has?

(map-has? [m :int h :int key :int])

check whether a key exists in the map.

mMap[K V]
hprecomputed hash of key
keykey of type K

true if the key is present, false otherwise.

(map-has? my-map (hash k) k)  ; => true or false

Since: Phase TM0

defn

map-count

(map-count [m :int])

return the number of entries in the map.

mMap[K V]

Integer count of key/value pairs.

(map-count my-map)  ; => 3

Since: Phase TM0

defn

map-merge

(map-merge [a :int b :int])

merge two maps; values from b win on key collision.

afirst Map[K V]
bsecond Map[K V] (wins on collision)

A new Map[K V] containing all entries from both maps.

(map-merge map-a map-b)  ; => merged map

Since: Phase TM0

defn

map-free

(map-free [m :int])

free the Map wrapper (does not free HAMT; use map-free-all for that).

mMap[K V] to free
(map-free my-map)

Since: Phase TM0

defn

map-eq?

(map-eq? [m1 :int m2 :int val-cmp])

compare two maps for structural equality using a value comparator.

m1first Map[K V]
m2second Map[K V]
val-cmpcomparator fn [a :int b :int] :bool applied to each value pair

true if both maps have identical keys and all corresponding values satisfy val-cmp.

(map-eq? ma mb (fn [a b] (= a b)))  ; => true

Since: Phase TM0

definstance

Eq[Map]

(definstance Eq [Map])

structural equality using the value type's Eq instance.