🐐 Dict
This commit is contained in:
35
README.md
35
README.md
@@ -127,6 +127,32 @@ Individual elements can be accessed by index using square brackets. Indexing is
|
||||
> I
|
||||
```
|
||||
|
||||
### Dicts (TABVLA)
|
||||
|
||||
Dicts are key-value maps created with the `TABVLA` keyword and curly braces:
|
||||
|
||||
```
|
||||
DESIGNA d VT TABVLA {"nomen" VT "Marcus", "aetas" VT XXV}
|
||||
```
|
||||
|
||||
Keys must be strings or integers. Values are accessed and assigned with square brackets:
|
||||
|
||||
```
|
||||
DICE(d["nomen"]) // → Marcus
|
||||
DESIGNA d["aetas"] VT XXVI // update existing key
|
||||
DESIGNA d["novus"] VT I // insert new key
|
||||
```
|
||||
|
||||
Iterating over a dict with `PER` loops over its keys:
|
||||
|
||||
```
|
||||
PER k IN d FACE {
|
||||
DICE(k)
|
||||
}
|
||||
```
|
||||
|
||||
`LONGITVDO(dict)` returns the number of entries. `CLAVES(dict)` returns the keys as an array.
|
||||
|
||||
## Conditionals
|
||||
### SI/TVNC
|
||||
If-then statements are denoted with the keywords `SI` (if) and `TVNC` (then). Thus, the code
|
||||
@@ -247,9 +273,14 @@ Skips the rest of the current loop body and continues to the next iteration (`DV
|
||||
Breaks out of the current loop (`DVM` or `PER`). Has no meaningful return value.
|
||||
|
||||
### LONGITVDO
|
||||
`LONGITVDO(array)` or `LONGITVDO(string)`
|
||||
`LONGITVDO(array)`, `LONGITVDO(string)`, or `LONGITVDO(dict)`
|
||||
|
||||
Returns the length of `array` (element count) or `string` (character count) as an integer.
|
||||
Returns the length of `array` (element count), `string` (character count), or `dict` (entry count) as an integer.
|
||||
|
||||
### CLAVES
|
||||
`CLAVES(dict)`
|
||||
|
||||
Returns the keys of `dict` as an array.
|
||||
|
||||
### SENATVS
|
||||
`SENATVS(bool, ...)` or `SENATVS([bool])`
|
||||
|
||||
Reference in New Issue
Block a user