Reference

Map

Constructor

Input A list of pairs separated by comma.
Output A map containing all the pairs.

Signature

{Any: Any, ...}: Map

Example

{"name": "Alice", "age": 30} // returns {"name": "Alice", "age": 30}

Index

Input A map and a key.
Output The value associated with the key.

Signature

Map[Any]: Any

Example

{"name": "Alice"}["name"] // returns "Alice"

At

Input A map and a hashable key.
Output The value associated with the key.

Signature

map_at(a: Map, b: Hashable): Any

Example

map_at({"name": "Alice"}, "name") // returns "Alice"

Keys

Input A map.
Output A list containing all the keys.

Signature

map_keys(a: Map): List

Example

map_keys({"a": 1, "b": 2}) // returns ["a", "b"]

Values

Input A map.
Output A list containing all the values.

Signature

map_values(a: Map): List

Example

map_values({"a": 1, "b": 2}) // returns [1, 2]

Entries

Input A map.
Output A list of key-value pairs as two-element lists.

Signature

map_entries(a: Map): List

Example

map_entries({"a": 1, "b": 2}) // returns [["a", 1], ["b", 2]]

Set

Input A map, a hashable key, and a value.
Output A new map containing the new key-value pair.

Signature

map_set(a: Map, b: Hashable, c: Any): Map

Example

map_set({"a": 1}, "b", 2) // returns {"a": 1, "b": 2}

Merge

Input Two maps.
Output A new map containing all key-value pairs from both maps. When both maps contain the same key, the value from the second map takes precedence.

Signature

map_merge(a: Map, b: Map): Map

Example

map_merge({"a": 1}, {"b": 2}) // returns {"a": 1, "b": 2}

Remove at

Input A map and a hashable key.
Output A new map with the key removed.

Signature

map_removeAt(a: Map, b: Hashable): Map

Example

map_removeAt({"a": 1, "b": 2}, "a") // returns {"b": 2}

Contains key

Input A map and a hashable key.
Output True if the key is in the map, false otherwise.

Signature

map_containsKey(a: Map, b: Hashable): Boolean

Example

map_containsKey({"a": 1}, "a") // returns true

Is empty

Input A map.
Output True if the map is empty, false otherwise.

Signature

map_isEmpty(a: Map): Boolean

Example

map_isEmpty({}) // returns true

Is not empty

Input A map.
Output True if the map is not empty, false otherwise.

Signature

map_isNotEmpty(a: Map): Boolean

Example

map_isNotEmpty({"a": 1}) // returns true

Length

Input A map.
Output The number of key-value pairs in the map.

Signature

map_length(a: Map): Number

Example

map_length({"a": 1, "b": 2}) // returns 2