map
Bundled cx-stdlib module.
map:get
[$map:get] (m::map, k::any) -> any — The value bound to key k, or the empty sequence when the key is absent — key identity is the (kind, image) pair, so an int 1 never finds a string '1'.
[?lib 'cx-stdlib/map']
[$map:get {port: 8080} 'port']
8080
map:keys
[$map:keys] (m::map) -> any — The sequence of keys in insertion order, each carrying its own kind.
[?lib 'cx-stdlib/map']
[$map:keys {a: 1, b: 2}]
(a, b)
map:size
[$map:size] (m::map) -> int — The entry count, declaration entries included.
[?lib 'cx-stdlib/map']
[$map:size {a: 1, b: 2}]
2
map:contains
[$map:contains] (m::map, k::any) -> bool — Whether the key is bound, under (kind, image) key identity.
[?lib 'cx-stdlib/map']
[$map:contains {a: 1} 'a']
true
map:put
[$map:put] (m::map, k::any, v::any) -> map — A new map with k bound to v — replacing in place when the key exists, appended last when new.
[?lib 'cx-stdlib/map']
[$map:put {a: 1} 'b' 2]
{a: 1, b: 2}
map:entry
[$map:entry] (k::any, v::any) -> map — The single-entry map holding k bound to v.
[?lib 'cx-stdlib/map']
[$map:entry 'a' 1]
{a: 1}
map:merge
[$map:merge] (maps::any) -> map — A sequence of maps folded left to right into one map; later bindings win on key collision, first occurrence fixes an entry's position.
[?lib 'cx-stdlib/map']
[$map:merge ({a: 1, b: 2}, {b: 9, c: 3})]
{a: 1, b: 9, c: 3}
map:remove
[$map:remove] (m::map, k::any) -> map — A new map without the key; a miss is the identity.
[?lib 'cx-stdlib/map']
[$map:remove {a: 1, b: 2} 'a']
{b: 2}
map:for-each
[$map:for-each] (m::map, fn::any) -> any — Apply a two-parameter function to each (key, value) pair in insertion order; the sequence of results.
[?lib 'cx-stdlib/map']
[$map:for-each {a: 1, b: 2} [?fn ($k $v) $v]]
(1, 2)