You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`dup`| (1 operand) Duplicates the top item. |`x dup *` is equivalent to `x 2 pow`.|
194
+
|`swap`| (2 operands) Swaps the top two items. |`x y swap -` is equivalent to `y x -`.|
195
+
|`dupN`| Duplicates the item N positions from the top. `dup0` is `dup`. ||
196
+
|`swapN`| Swaps the top item with the item N positions down. `swap1` is `swap`. ||
197
+
|`drop` / `dropN`| Drops the top N items. `drop` is an alias for `drop1`. |`1 2 3 drop2` results in a stack of `[1]`.|
198
+
|`sortN`| Sorts the top N items, with the smallest value ending up on top.|`3 1 2 sort3` results in a stack of `[3, 2, 1]`. |
199
199
200
200
#### **4.2. Named Variables**
201
201
@@ -340,10 +340,10 @@ Since `SingleExpr` has no concept of a "current pixel," all data I/O must be exp
340
340
341
341
These operators provide fine-grained control over the default per-pixel output behavior in `Expr`. They are not available in `SingleExpr`.
342
342
343
-
| Operator | Operands | Description |
344
-
| :--- | :--- | :--- |
345
-
| `@[]` | 3 | `val absX absY @[]` pops a value `val` and two coordinates `absX`, `absY`, and writes `val` to the output pixel at `[absX, absY]` *in the current plane*. This allows an expression for one pixel to write to another. If the coordinates are not integers, they will be truncated to integers. |
346
-
| `^exit^` | 0 | Pushes a special marker value onto the stack. If, after the entire `Expr` expression is evaluated for a pixel, this marker is the *only* item remaining on the stack, the default write to the current pixel `[X, Y]` is suppressed. This is useful in expressions that only use `@[]` to write to other pixels. |
| `@[]` | 3 | `val absX absY @[]` pops a value `val` and two coordinates `absX`, `absY`, and writes `val` to the output pixel at `[absX, absY]` *in the current plane*. This allows an expression for one pixel to write to another. If the coordinates are not integers, they will be truncated to integers. |
346
+
| `^exit^` | 0 | Pushes a special marker value onto the stack. If, after the entire `Expr` expression is evaluated for a pixel, this marker is the *only* item remaining on the stack, the default write to the current pixel `[X, Y]` is suppressed. This is useful in expressions that only use `@[]` to write to other pixels. |
347
347
348
348
**Stack Requirements at Exit:**
349
349
- **`Expr`:** The stack must contain exactly one value, which becomes the output for the current pixel. Alternatively, it can contain only the `^exit^` marker to suppress output.
@@ -384,23 +384,20 @@ The following expression calculates `x` to the power of 4, equivalent to `x 4 po
384
384
385
385
**Execution Trace:**
386
386
387
-
1. **Pre-initialization (automatic):**
388
-
- All variables (`base`, `result`, `counter`) are automatically allocated and initialized to `0.0`.
389
-
390
-
2. **Initialization:**
387
+
1. **Initialization:**
391
388
- `x base!`: Stores the pixel value of clip `x` into the variable `base`.
392
389
- `1 result!`: Initializes `result` to 1.
393
390
- `4 counter!`: Initializes a loop `counter` to 4.
0 commit comments