🐐 Snippets
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:
|
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:
|
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
|
## Data types
|
||||||
### NVLLVS
|
### NVLLVS
|
||||||
@@ -69,12 +64,7 @@ Strings are concatenated with `&`:
|
|||||||
|
|
||||||
Double-quoted strings support interpolation with `{expression}`:
|
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.).
|
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:
|
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:
|
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:
|
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.
|
`LONGITVDO(dict)` returns the number of entries. `CLAVES(dict)` returns the keys as an array.
|
||||||
|
|
||||||
|
|||||||
BIN
snippets/aeternvm.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.1 KiB |
1
snippets/destructure_array.cent
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DESIGNA a, b, c VT [I, II, III]
|
||||||
BIN
snippets/destructure_array.png
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
2
snippets/destructure_fn.cent
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
DEFINI pair (a, b) VT { REDI (a, b) }
|
||||||
|
DESIGNA x, y VT INVOCA pair (III, VII)
|
||||||
BIN
snippets/destructure_fn.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
3
snippets/dict_access.cent
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
DICE(d["nomen"])
|
||||||
|
DESIGNA d["aetas"] VT XXVI
|
||||||
|
DESIGNA d["novus"] VT I
|
||||||
BIN
snippets/dict_access.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
1
snippets/dict_create.cent
Normal file
@@ -0,0 +1 @@
|
|||||||
|
DESIGNA d VT TABVLA {"nomen" VT "Marcus", "aetas" VT XXV}
|
||||||
BIN
snippets/dict_create.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
3
snippets/dict_per.cent
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
PER k IN d FACE {
|
||||||
|
DICE(k)
|
||||||
|
}
|
||||||
BIN
snippets/dict_per.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
4
snippets/string_interp.cent
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
DESIGNA nomen VT "Marcus"
|
||||||
|
DICE("Salve, {nomen}!")
|
||||||
|
DICE("Sum: {III + IV}")
|
||||||
|
DICE("{nomen} has {V} cats")
|
||||||
BIN
snippets/string_interp.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
@@ -9,8 +9,8 @@ contexts:
|
|||||||
main:
|
main:
|
||||||
- include: comments
|
- include: comments
|
||||||
- include: strings
|
- include: strings
|
||||||
- include: fractions
|
|
||||||
- include: keywords
|
- include: keywords
|
||||||
|
- include: fractions
|
||||||
- include: numerals
|
- include: numerals
|
||||||
- include: constants
|
- include: constants
|
||||||
- include: builtins
|
- include: builtins
|
||||||
|
|||||||