🐐 Snippets
This commit is contained in:
32
README.md
32
README.md
@@ -38,16 +38,11 @@ Variable can consist of lower-case letters, numbers, as well as `_`.
|
||||
|
||||
Multiple variables can be assigned at once by unpacking an array or multi-return function:
|
||||
|
||||
```
|
||||
DEFINI pair (a, b) VT { REDI (a, b) }
|
||||
DESIGNA x, y VT INVOCA pair (III, VII)
|
||||
```
|
||||

|
||||
|
||||
The number of targets must match the length of the array. This also works with array literals:
|
||||
|
||||
```
|
||||
DESIGNA a, b, c VT [I, II, III]
|
||||
```
|
||||

|
||||
|
||||
## Data types
|
||||
### NVLLVS
|
||||
@@ -69,12 +64,7 @@ Strings are concatenated with `&`:
|
||||
|
||||
Double-quoted strings support interpolation with `{expression}`:
|
||||
|
||||
```
|
||||
DESIGNA nomen VT "Marcus"
|
||||
DICE("Salve, {nomen}!") // → Salve, Marcus!
|
||||
DICE("Sum: {III + IV}") // → Sum: VII
|
||||
DICE("{nomen} has {V} cats") // → Marcus has V cats
|
||||
```
|
||||

|
||||
|
||||
Any expression can appear inside `{}`. Values are coerced to strings the same way as with `&` (integers become Roman numerals, booleans become `VERITAS`/`FALSITAS`, etc.).
|
||||
|
||||
@@ -131,25 +121,15 @@ Individual elements can be accessed by index using square brackets. Indexing is
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user