diff options
Diffstat (limited to 'docs/doc/scan.html')
| -rw-r--r-- | docs/doc/scan.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/doc/scan.html b/docs/doc/scan.html index c975e35c..bac2f4c5 100644 --- a/docs/doc/scan.html +++ b/docs/doc/scan.html @@ -58,7 +58,7 @@ </g> </svg> -<p>The 1-modifier Scan (<code><span class='Modifier'>`</span></code>) moves along the first axis of the array <code><span class='Value'>๐ฉ</span></code>, building up an array of results by applying <code><span class='Function'>๐ฝ</span></code> repeatedly beginning with <code><span class='Value'>๐จ</span></code> or <code><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>. It's related to the fold modifiers, and most closely resembles the <a href="fold.html#apl2-reduction">APL2-style reduction</a> <code><span class='Modifier'>ยจห</span></code>, but it traverses the array in forward rather than reverse index order, and includes all intermediate results of <code><span class='Function'>๐ฝ</span></code> in its output instead of just the final one.</p> +<p>The 1-modifier Scan (<code><span class='Modifier'>`</span></code>) moves along the first axis of the array <code><span class='Value'>๐ฉ</span></code>, building up an array of results by applying <code><span class='Function'>๐ฝ</span></code> repeatedly beginning with <code><span class='Value'>๐จ</span></code> or <code><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>. It's related to the <a href="fold.html">fold</a> modifiers, and most closely resembles the <a href="fold.html#apl2-reduction">APL2-style reduction</a> <code><span class='Modifier'>ยจห</span></code>, but it traverses the array in forward rather than reverse index order, and includes all intermediate results of <code><span class='Function'>๐ฝ</span></code> in its output instead of just the final one.</p> <p>BQN's Scan is ordered differently from Scan in APL. Both include one result for each non-empty prefix of <code><span class='Value'>๐ฉ</span></code>. In BQN this is a left-to-right fold, so that each new result requires one application of <code><span class='Function'>๐ฝ</span></code>. APL uses right-to-left folds, which matches with reduction, but requires starting over at the end for each new prefix, except in special cases. If needed, this definition can be obtained with a fold on each <a href="prefixes.html">prefix</a> except the first (which is empty). In the particular case of <code><span class='Function'>-</span><span class='Value'>โ</span></code>, that nested solution isn't needed: negate odd-indexed elements and then apply <code><span class='Function'>+</span><span class='Modifier'>`</span></code>.</p> <p>Scan also differs from Fold or Insert in that it never depends on <code><span class='Function'>๐ฝ</span></code>'s <a href="fold.html#identity-values">identity value</a>, because scanning over an empty array simply returns that array.</p> <h2 id="lists"><a class="header" href="#lists">Lists</a></h2> @@ -142,7 +142,7 @@ ยฏ2 0.25 'a' โ โ </pre> -<p>If <code><span class='Value'>๐จ</span></code> is given, it must have the same shape as a major cell of <code><span class='Value'>๐ฉ</span></code> (this is why <code><span class='Value'>๐จ</span></code> needs to be enclosed when <code><span class='Value'>๐ฉ</span></code> is a list: in general it's an array). Then the first result cell is found by applying <code><span class='Function'>๐ฝ</span></code> to elements of <code><span class='Value'>๐จ</span></code> and <code><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>, and the computation continues as in the one-argument case for remaining cells.</p> +<p>If <code><span class='Value'>๐จ</span></code> is given, it must have the same shape as a <a href="array.html#cells">major cell</a> of <code><span class='Value'>๐ฉ</span></code> (this is why <code><span class='Value'>๐จ</span></code> needs to be enclosed when <code><span class='Value'>๐ฉ</span></code> is a list: in general it's an array). Then the first result cell is found by applying <code><span class='Function'>๐ฝ</span></code> to elements of <code><span class='Value'>๐จ</span></code> and <code><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>, and the computation continues as in the one-argument case for remaining cells.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=M+KAvzLigL8x4oC/MCArYCBh">โ๏ธ</a><pre> <span class='Number'>3</span><span class='Ligature'>โฟ</span><span class='Number'>2</span><span class='Ligature'>โฟ</span><span class='Number'>1</span><span class='Ligature'>โฟ</span><span class='Number'>0</span> <span class='Function'>+</span><span class='Modifier'>`</span> <span class='Value'>a</span> โโ โต 1 2.25 'b' โ |
