diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-08-07 20:41:31 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-08-07 20:41:31 -0400 |
| commit | 7bf2aa4054b8378a76dff63acdccbcdad91f68e6 (patch) | |
| tree | 1bff7a2a2b11fa259bc80722fdcb0609768c7718 /docs/doc/find.html | |
| parent | 532796eb397c8374e0546de9e4ab70c2955349f3 (diff) | |
BREAKING: Don't allow First of empty or reshaping empty to non-empty
Diffstat (limited to 'docs/doc/find.html')
| -rw-r--r-- | docs/doc/find.html | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/doc/find.html b/docs/doc/find.html index bc883db2..1421500e 100644 --- a/docs/doc/find.html +++ b/docs/doc/find.html @@ -32,14 +32,14 @@ <span class='String'>"string"</span> <span class='Paren'>(</span><span class='Function'>≢</span><span class='Modifier2'>∘</span><span class='Function'>⊢↑⍷</span><span class='Paren'>)</span> <span class='String'>"substring"</span> <span class='Comment'># APL style </span>⟨ 0 0 0 1 0 0 0 0 0 ⟩ </pre> -<p>If <code><span class='Value'>𝕨</span></code> is larger than <code><span class='Value'>𝕩</span></code>, the result is empty, and there's no error even in cases where Windows would fail. One place this tends to come up is when applying <a href="pick.html">First</a> (<code><span class='Function'>⊑</span></code>) the result: <code><span class='Function'>⊑⍷</span></code> tests whether <code><span class='Value'>𝕨</span></code> appears in <code><span class='Value'>𝕩</span></code> at the first position, that is, whether it's a prefix of <code><span class='Value'>𝕩</span></code>. If <code><span class='Value'>𝕨</span></code> is longer than <code><span class='Value'>𝕩</span></code> it shouldn't be a prefix, so 0 is appropriate.</p> -<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Imxvb29vb29uZyIg4o23ICJzaG9ydCIKCjkg4oaVICJzaG9ydCIKCuKKkSAibG9vb29vb25nIiDijbcgInNob3J0Ig==">↗️</a><pre> <span class='String'>"loooooong"</span> <span class='Function'>⍷</span> <span class='String'>"short"</span> +<p>If <code><span class='Value'>𝕨</span></code> is larger than <code><span class='Value'>𝕩</span></code>, the result is empty, and there's no error even in cases where Windows would fail. One place this tends to come up is when applying <a href="pick.html#first">First</a> (<code><span class='Function'>⊑</span></code>) the result: <code><span class='Function'>⊑⍷</span></code> tests whether <code><span class='Value'>𝕨</span></code> appears in <code><span class='Value'>𝕩</span></code> at the first position, that is, whether it's a prefix of <code><span class='Value'>𝕩</span></code>. If <code><span class='Value'>𝕨</span></code> is longer than <code><span class='Value'>𝕩</span></code> it shouldn't be a prefix. First will fail but using a <a href="fold.html">fold</a> <code><span class='Number'>0</span><span class='Function'>⊣</span><span class='Modifier'>´</span><span class='Function'>⥊</span><span class='Modifier2'>∘</span><span class='Function'>⍷</span></code> instead gives a 0 in this case.</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Imxvb29vb29uZyIg4o23ICJzaG9ydCIKCjkg4oaVICJzaG9ydCIKCjAg4oqjwrQgImxvb29vb29uZyIg4o23ICJzaG9ydCI=">↗️</a><pre> <span class='String'>"loooooong"</span> <span class='Function'>⍷</span> <span class='String'>"short"</span> ⟨⟩ <span class='Number'>9</span> <span class='Function'>↕</span> <span class='String'>"short"</span> ERROR - <span class='Function'>⊑</span> <span class='String'>"loooooong"</span> <span class='Function'>⍷</span> <span class='String'>"short"</span> + <span class='Number'>0</span> <span class='Function'>⊣</span><span class='Modifier'>´</span> <span class='String'>"loooooong"</span> <span class='Function'>⍷</span> <span class='String'>"short"</span> 0 </pre> <p>This pattern also works in the high-rank case discussed below, testing whether <code><span class='Value'>𝕨</span></code> is a multi-dimensional prefix starting at the lowest-index corner of <code><span class='Value'>𝕩</span></code>.</p> |
