aboutsummaryrefslogtreecommitdiff
path: root/rprt.md
diff options
context:
space:
mode:
Diffstat (limited to 'rprt.md')
-rw-r--r--rprt.md20
1 files changed, 18 insertions, 2 deletions
diff --git a/rprt.md b/rprt.md
index ee1299f..12449ca 100644
--- a/rprt.md
+++ b/rprt.md
@@ -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: