🐐 Snippets

This commit is contained in:
2026-04-24 15:37:46 +02:00
parent 27c5f7bf56
commit 92301f3ff6
11 changed files with 23 additions and 19 deletions

View File

@@ -74,15 +74,19 @@ Single-quoted strings do **not** interpolate — `'{nomen}'` is the literal text
Strings support the same indexing and slicing syntax as arrays. Indexing is 1-based and returns a single-character string: Strings support the same indexing and slicing syntax as arrays. Indexing is 1-based and returns a single-character string:
![String indexing](snippets/string_index.png)
``` ```
"SALVTE"[I] @> "S" > S
"SALVTE"[III] @> "L" > L
``` ```
Slicing uses `VSQVE` with inclusive bounds, returning a substring: Slicing uses `VSQVE` with inclusive bounds, returning a substring:
![String slicing](snippets/string_slice.png)
``` ```
"SALVTE"[II VSQVE IV] @> "ALV" > ALV
``` ```
Integer modulo is `RELIQVVM`: `VII RELIQVVM III` evaluates to `I`. Under the `FRACTIO` module it returns a fraction, so `IIIS RELIQVVM IS` is `S` (i.e. 1/2). Integer modulo is `RELIQVVM`: `VII RELIQVVM III` evaluates to `I`. Under the `FRACTIO` module it returns a fraction, so `IIIS RELIQVVM IS` is `S` (i.e. 1/2).
@@ -138,10 +142,7 @@ Individual elements can be accessed by index using square brackets. Indexing is
Arrays are concatenated with `@`: Arrays are concatenated with `@`:
``` ![Array concatenation](snippets/array_concat.png)
DESIGNA x VT [I, II, III] @ [IV, V]
DIC x
```
``` ```
> [I, II, III, IV, V] > [I, II, III, IV, V]
@@ -255,11 +256,7 @@ condition. Exit the loop with `ERVMPE` (or `REDI` from inside a function).
Variables can be unpacked in `PER` loops, similar to `DESIGNA` destructuring: Variables can be unpacked in `PER` loops, similar to `DESIGNA` destructuring:
``` ![PER destructuring](snippets/per_destructure.png)
PER a, b IN [[I, II], [III, IV]] FAC {
DIC(a + b)
}
```
``` ```
> III > III
@@ -270,13 +267,7 @@ PER a, b IN [[I, II], [III, IV]] FAC {
Errors can be caught using `TEMPTA` (temptare = to try) and `CAPE` (capere = to catch). The `CAPE` block binds the error message to a variable as a string. Errors can be caught using `TEMPTA` (temptare = to try) and `CAPE` (capere = to catch). The `CAPE` block binds the error message to a variable as a string.
``` ![TEMPTA / CAPE](snippets/tempta_cape.png)
TEMPTA {
DESIGNA x VT I / NVLLVS
} CAPE error {
DIC(error)
}
```
``` ```
> Division by zero > Division by zero

View File

@@ -0,0 +1,2 @@
DESIGNA x VT [I, II, III] @ [IV, V]
DIC(x)

BIN
snippets/array_concat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,3 @@
PER a, b IN [[I, II], [III, IV]] FAC {
DIC(a + b)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,2 @@
DIC("SALVTE"[I])
DIC("SALVTE"[III])

BIN
snippets/string_index.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1 @@
DIC("SALVTE"[II VSQVE IV])

BIN
snippets/string_slice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@@ -0,0 +1,5 @@
TEMPTA {
DESIGNA x VT I / NVLLVS
} CAPE error {
DIC(error)
}

BIN
snippets/tempta_cape.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB