diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-11 14:58:27 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-11 14:58:27 -0500 |
| commit | ae8d0791777e9ff3e43569089ddd446b666ac626 (patch) | |
| tree | 51a9ceac3d9550e9ab40799b4d63ee496409dae6 /spec/primitive.md | |
| parent | f07e748444200bad23c6a44a30af82bc7b7c8e48 (diff) | |
Allow a left argument to Scan (`)
Diffstat (limited to 'spec/primitive.md')
| -rw-r--r-- | spec/primitive.md | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/spec/primitive.md b/spec/primitive.md index 7fb3cd83..ba7a7805 100644 --- a/spec/primitive.md +++ b/spec/primitive.md @@ -133,6 +133,8 @@ The iteration modifiers `⌜¨⚇˘⎉` process elements or cells in index order **Fold** (`´`), **Insert** (`˝`), and **Scan** (`` ` ``) repeatedly apply a function between parts of an array. Fold requires the argument to have rank 1 and applies the operand between its elements, while Insert requires it to have rank 1 or more and applies it between the cells. For each of these two functions, the operand is applied beginning at the end of the array, and an [identity](inferred.md#identities) value is returned if the array is empty. While these functions reduce multiple values to a single result, Scan returns many results and preserves the shape of its argument. It requires the argument to have rank at least 1, and applies the function between elements along columns—that is, from one element in a major cell to the one in the same position of the next major cell. This application begins at the first major cell of the array. Scan never uses the identity element of its operand because if the argument is empty then the result, which has the same shape, will be empty as well. +A left argument for any of the three reduction-based modifiers indicates an initial value to be used, so that the first application of the operand function applies not to two values from `𝕩` but instead to a value from `𝕨` and a value from `𝕩`. In Fold and Insert, the entire value `𝕨` is the initial value, while in Scan, `𝕨` is an array of initial values, which must have shape `1↓≢𝕩`. + **Repeat** (`⍟`) applies the operand function, or its [inverse](inferred.md#undo), several times in sequence. The right operand must consist only of integer atoms (arranged in arrays of any depth), and each number there is replaced with the application of the left operand that many times to the arguments. If a left argument is present, then it's reused each time, as if it were bound to the operand function. For a negative number `-n`, the function is "applied" `-n` times by undoing it `n` times. In both directions, the total number of times the function is applied is the maximum of all numbers present: results must be saved if intermediate values are needed. ### Restructuring |
