diff options
| author | tslil <tslil@posteo.de> | 2026-03-09 22:25:44 +0000 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-03-19 10:04:12 +0000 |
| commit | 5a5da7bc299bee12072e421d1936554690e34dd6 (patch) | |
| tree | 1eb75f22f2cf5b4123581f3be2417ce9ee235391 /rprt.md | |
| parent | 0d734cd4095c57be5c6a527adf49504ca1d14863 (diff) | |
clarify top-level semantics
Diffstat (limited to 'rprt.md')
| -rw-r--r-- | rprt.md | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -75,10 +75,12 @@ The buffer axis (rank 3) is the **leading axis**: operations on rank 3 selection A **train** is a sequence of functions that compose according to specific rules, following [APL train syntax](https://aplwiki.com/wiki/Train). **2-train (Atop)** `F G`: +- Niladic: `(F G) = F (G)` - Monadic: `(F G) ω = F (G ω)` - Dyadic: `α (F G) ω = F (α G ω)` **3-train (Fork)** `F G H`: +- Niladic: `(F G H) = (F) G (H)` - Monadic: `(F G H) ω = (F ω) G (H ω)` - Dyadic: `α (F G H) ω = (α F ω) G (α H ω)` @@ -91,10 +93,12 @@ A **train** is a sequence of functions that compose according to specific rules, RPRT provides two explicit hook combinators from BQN for flexible function composition: **Before (Left Hook)** `F>G`: +- Niladic: `(F>G) = (F) G` - Monadic: `(F>G) ω = (F ω) G ω` - Dyadic: `α (F>G) ω = (F α) G ω` **After (Right Hook)** `F<G`: +- Niladic: `(F<G) = F (G)` - Monadic: `(F<G) ω = ω F (G ω)` - Dyadic: `α (F<G) ω = α F (G ω)` @@ -112,9 +116,9 @@ Selection and Text functions have signatures `EditorState Selection` and `Editor ## 1.5 Evaluation Contexts -**Top-level Selection:** Sets the editor's current selection. +**Top-level Selection:** At the top level, all expressions are evaluated niladically (with no arguments). The result is used to set the editor's current selection. ``` -α # Finds pattern AND sets editor selection to it +F # Applies selection function F niladically and sets the selection to the result ``` **All text operations:** Modify editor content. Note that `F` returns a selection, so at the top level this also changes the current selection. @@ -207,6 +211,18 @@ The span function `-` is the only selection function with dyadic semantics. It c | 3 | 1/2 | - | Erroneous (TODO: maybe makes sense if indices align?) | | 1/2 | 3 | - | Erroneous (TODO: maybe makes sense if indices align?) | +### 2.1.1 Examples: Searching Within Buffer vs Current Selection + +Because top-level expressions are evaluated niladically (§1.5), searching requires explicit composition to operate on the current selection (see §3.1, Text function `.`): + +**Search from buffer start:** `/re/` +Niladic application searches from beginning of buffer + +**Search within current selection:** `.>/re/` +In the niladic form this is `(.) /re/` (left hook semantics, §1.2), and `.` niladically is the current selection (§3.1). Thus `.>/re/` applies `/re/` to the current selection. + +The After hook `F<G` has niladic semantics `F (G)`, making `.< /re/` evaluate to `/re/ (.)`—applying the search function to the current selection. + ## 2.2 Selection Function Operators Operators take functions as arguments and return new functions. Selection function operators fall into two categories which compose in a restricted manner: |
