Reference
Map
Constructor
| Input | A list of pairs separated by comma. |
|---|---|
| Output | A map containing all the pairs. |
Signature
{Any: Any, ...}: MapExample
{"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]: AnyExample
{"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): AnyExample
map_at({"name": "Alice"}, "name") // returns "Alice"Keys
| Input | A map. |
|---|---|
| Output | A list containing all the keys. |
Signature
map_keys(a: Map): ListExample
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): ListExample
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): ListExample
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): MapExample
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): MapExample
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): MapExample
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): BooleanExample
map_containsKey({"a": 1}, "a") // returns trueIs empty
| Input | A map. |
|---|---|
| Output | True if the map is empty, false otherwise. |
Signature
map_isEmpty(a: Map): BooleanExample
map_isEmpty({}) // returns trueIs not empty
| Input | A map. |
|---|---|
| Output | True if the map is not empty, false otherwise. |
Signature
map_isNotEmpty(a: Map): BooleanExample
map_isNotEmpty({"a": 1}) // returns trueLength
| Input | A map. |
|---|---|
| Output | The number of key-value pairs in the map. |
Signature
map_length(a: Map): NumberExample
map_length({"a": 1, "b": 2}) // returns 2