Map
all?
(λ [(Ref (λ [&a, &b] Bool)), (Ref (Map a b))] Bool)
(all? pred m)
Do all key-value pairs pass the given predicate (of two arguments)?
buckets
(λ [(Ref (Map a b))] (Ref (Array (Bucket a b))))
gets the buckets
property of a Map
.
contains?
(λ [(Ref (Map a b)), &a] Bool)
(contains? m k)
Check whether the map m contains the key k.
create-with-len
(λ [Int] (Map a b))
(create-with-len len)
Create an empty map with a given number of buckets. High numbers reduce the possibility of hash collisions while increasing the memory footprint.
endo-map
(λ [(Ref (λ [&a, &b] b)), (Map a b)] (Map a b))
(endo-map f m)
Transform values of the given map in place. f gets two arguments, key and value, and should return new value
for-each
(λ [(Ref (Map a b)), (Ref (λ [&a, &b] ()))] ())
(for-each m f)
Execute the binary function f for all keys and values in the map m.
from-array
(λ [(Ref (Array (Pair a b)))] (Map a b))
(from-array a)
Create a map from the array a containing key-value pairs.
get
(λ [(Ref (Map a b)), &a] b)
(get m k)
Get the value for the key k from map m. If it isn’t found, a zero element for the value type is returned.
get-maybe
(λ [(Ref (Map a b)), &a] (Maybe b))
(get-maybe m k)
Get the value for the key k from map m. It returns a Maybe type, meaning that if nothing is found, Nothing is returned.
get-with-default
(λ [(Ref (Map a b)), &a, &b] b)
(get-with-default m k default-value)
Get the value for the key k from map m. If it isn’t found, the default is returned.
keys
(λ [(Ref (Map a b))] (Array a))
(keys m)
Return an array of the keys of the map. Order corresponds to order of (vals m)
kv-reduce
(λ [(Ref (λ [a, &b, &c] a)), a, (Ref (Map b c))] a)
(kv-reduce f init m)
Reduce a map with a function of three arguments: state, key and value. Reduction order is not guaranteed.
put!
(λ [(Ref (Map a b)), &a, &b] ())
(put! m k v)
Put a a value v into map m, using the key k, in place.
remove
(λ [(Map a b), &a] (Map a b))
(remove m k)
Remove the value under the key k from the map m.
reverse
(λ [(Ref (Map a b))] (Map b a))
(reverse m)
reverses they keys and values in a given map m
.
set-buckets
(λ [(Map a b), (Array (Bucket a b))] (Map a b))
sets the buckets
property of a Map
.
set-buckets!
(λ [(Ref (Map a b)), (Array (Bucket a b))] ())
sets the buckets
property of a Map
in place.
set-n-buckets!
(λ [(Ref (Map a b)), Int] ())
sets the n-buckets
property of a Map
in place.
update
(λ [(Map a b), &a, (Ref (λ [b] b))] (Map a b))
(update m k f)
Update value at key k in map with function f, if it exists.
update-buckets
(λ [(Map a b), (Ref (λ [(Array (Bucket a b))] (Array (Bucket a b))))] (Map a b))
updates the buckets
property of a Map
using a function f
.
update-n-buckets
(λ [(Map a b), (Ref (λ [Int] Int))] (Map a b))
updates the n-buckets
property of a Map
using a function f
.
update-with-default
(λ [(Map a b), &a, (Ref (λ [b] b)), b] (Map a b))
(update-with-default m k f v)
Update value at key k in map with function f. If k doesn't exist in map, set k to (f v).
vals
(λ [(Ref (Map a b))] (Array b))
(vals m)
Return an array of the values of the map. Order corresponds to order of (keys m)