Maps
11 entries. What each one takes, what it returns, and a working example.
Does not return a value; removes all pairs from the map (the map is emptied in place).
The same map object is kept, only its contents are cleared; other variables holding it see it empty too.
m = mapNew() mapPut(m, "a", 1) mapClear(m) plot(mapSize(m))
One pair is written then the map is cleared; the size 0 is plotted.
true if the key exists in the map, otherwise false.
A value being na is different from the key being absent; this function only checks whether the key exists.
m = mapNew() mapPut(m, "a", 1) plot(iff(mapContains(m, "a"), 1, 0))
Since key "a" was written, it plots 1.
The copy is independent — writing to the copy does not affect the original. Useful for branching a new state.
a = mapNew() mapPut(a, "x", 1) b = mapCopy(a) mapPut(b, "y", 2) plot(mapSize(a))
A new pair is added to the copy, but the original still holds one pair so its size 1 is plotted.
The value at the key, or na if the key is absent (or the input is not a map).
A missing key does not raise an error, it returns na — conditions run safely over na.
m = mapNew() mapPut(m, "tepe", highest(high, 20)) plot(mapGet(m, "tepe"))
Stores the 20-bar highest level under the "tepe" key and reads it back to plot it.
An array holding the map's keys in insertion order.
You can read the array's length with arraySize and walk its elements with the array functions.
m = mapNew() mapPut(m, "a", 1) mapPut(m, "b", 2) plot(arraySize(mapKeys(m)))
Two keys are written; the length of the key array, 2, is plotted.
A map holds key→value pairs; writing the same key again overwrites the old value. Values may be numbers, text, booleans or series.
m = mapNew() mapPut(m, "esik", 42) plot(iff(mapContains(m, "esik"), close, open))
Creates an empty map, writes 42 under the "esik" key; since the key exists it plots close.
mapPut(harita, anahtar, değer)
The value previously held at the key, or na if the key was absent. The map is changed in place.
If the key already exists its value is updated and the old value is returned; otherwise a new pair is added and na is returned.
m = mapNew() onceki = mapPut(m, "k", 10) mapPut(m, "k", 20) plot(mapGet(m, "k"))
Writes 10 then 20 under key "k"; the previous value is na on the first write. The final value 20 is plotted.
Does not return a value; copies all pairs from map2 into map1 (colliding keys are overwritten).
Only the target (map1) changes; the source (map2) is left unchanged.
a = mapNew() mapPut(a, "x", 1) b = mapNew() mapPut(b, "y", 2) mapPutAll(a, b) plot(mapSize(a))
b's pair is added to a; a now holds two pairs so the size 2 is plotted.
The value of the removed key, or na if the key was absent. The map is changed in place.
If the key is absent it silently returns na with no error.
m = mapNew() mapPut(m, "a", 5) mapRemove(m, "a") plot(iff(mapContains(m, "a"), 1, 0))
Key "a" is written then removed; since it is no longer present it plots 0.
The number of key-value pairs in the map; 0 if the input is not a map.
Returns 0 for an empty map. Writing the same key again does not increase the size.
m = mapNew() mapPut(m, "a", 1) mapPut(m, "b", 2) plot(mapSize(m))
Two distinct keys are written; the size 2 is plotted.
An array holding the map's values in key insertion order.
For numeric values you can aggregate with array functions such as arraySum / arrayAvg.
m = mapNew() mapPut(m, "a", 10) mapPut(m, "b", 20) plot(arraySum(mapValues(m)))
Values are 10 and 20; the sum of the value array, 30, is plotted.