diff --git a/README.md b/README.md index 13551db..a8a4eee 100644 --- a/README.md +++ b/README.md @@ -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: +![String indexing](snippets/string_index.png) + ``` -"SALVTE"[I] @> "S" -"SALVTE"[III] @> "L" +> S +> L ``` 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). @@ -138,10 +142,7 @@ Individual elements can be accessed by index using square brackets. Indexing is Arrays are concatenated with `@`: -``` -DESIGNA x VT [I, II, III] @ [IV, V] -DIC x -``` +![Array concatenation](snippets/array_concat.png) ``` > [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: -``` -PER a, b IN [[I, II], [III, IV]] FAC { - DIC(a + b) -} -``` +![PER destructuring](snippets/per_destructure.png) ``` > 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. -``` -TEMPTA { - DESIGNA x VT I / NVLLVS -} CAPE error { - DIC(error) -} -``` +![TEMPTA / CAPE](snippets/tempta_cape.png) ``` > Division by zero diff --git a/snippets/array_concat.cent b/snippets/array_concat.cent new file mode 100644 index 0000000..9282a7f --- /dev/null +++ b/snippets/array_concat.cent @@ -0,0 +1,2 @@ +DESIGNA x VT [I, II, III] @ [IV, V] +DIC(x) diff --git a/snippets/array_concat.png b/snippets/array_concat.png new file mode 100644 index 0000000..f01339b Binary files /dev/null and b/snippets/array_concat.png differ diff --git a/snippets/per_destructure.cent b/snippets/per_destructure.cent new file mode 100644 index 0000000..5fdfa3a --- /dev/null +++ b/snippets/per_destructure.cent @@ -0,0 +1,3 @@ +PER a, b IN [[I, II], [III, IV]] FAC { + DIC(a + b) +} diff --git a/snippets/per_destructure.png b/snippets/per_destructure.png new file mode 100644 index 0000000..65a0e6a Binary files /dev/null and b/snippets/per_destructure.png differ diff --git a/snippets/string_index.cent b/snippets/string_index.cent new file mode 100644 index 0000000..689149b --- /dev/null +++ b/snippets/string_index.cent @@ -0,0 +1,2 @@ +DIC("SALVTE"[I]) +DIC("SALVTE"[III]) diff --git a/snippets/string_index.png b/snippets/string_index.png new file mode 100644 index 0000000..0a5b35d Binary files /dev/null and b/snippets/string_index.png differ diff --git a/snippets/string_slice.cent b/snippets/string_slice.cent new file mode 100644 index 0000000..eebdeda --- /dev/null +++ b/snippets/string_slice.cent @@ -0,0 +1 @@ +DIC("SALVTE"[II VSQVE IV]) diff --git a/snippets/string_slice.png b/snippets/string_slice.png new file mode 100644 index 0000000..ce52e28 Binary files /dev/null and b/snippets/string_slice.png differ diff --git a/snippets/tempta_cape.cent b/snippets/tempta_cape.cent new file mode 100644 index 0000000..cd778ce --- /dev/null +++ b/snippets/tempta_cape.cent @@ -0,0 +1,5 @@ +TEMPTA { + DESIGNA x VT I / NVLLVS +} CAPE error { + DIC(error) +} diff --git a/snippets/tempta_cape.png b/snippets/tempta_cape.png new file mode 100644 index 0000000..b03219a Binary files /dev/null and b/snippets/tempta_cape.png differ