diff options
Diffstat (limited to 'docs/doc/find.html')
| -rw-r--r-- | docs/doc/find.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/doc/find.html b/docs/doc/find.html index 09632469..01efff6d 100644 --- a/docs/doc/find.html +++ b/docs/doc/find.html @@ -9,7 +9,7 @@ <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Inh4IiDijbcgInh4YmR4eHhjeCI=">↗️</a><pre> <span class='String'>"xx"</span> <span class='Function'>⍷</span> <span class='String'>"xxbdxxxcx"</span> ⟨ 1 0 0 0 1 1 0 0 ⟩ </pre> -<p>More precisely <code><span class='Value'>𝕨</span></code> needs to <a href="match.html">match</a> a contiguous selection from <code><span class='Value'>𝕩</span></code>, which for strings means a substring. These subarrays of <code><span class='Value'>𝕩</span></code> are also exactly the cells in the result of <a href="windows.html">Windows</a>. In fact we can use Windows to see all the arrays <code><span class='Value'>𝕨</span></code> will be compared against.</p> +<p>More precisely, <code><span class='Value'>𝕨</span></code> needs to <a href="match.html">match</a> a contiguous selection from <code><span class='Value'>𝕩</span></code>, which for strings means a substring. These subarrays of <code><span class='Value'>𝕩</span></code> are also exactly the cells in the result of <a href="windows.html">Windows</a>. So we can use Windows to see all the arrays <code><span class='Value'>𝕨</span></code> will be compared against.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDihpUgInh4YmR4eHhjeCIKCiJ4eCLiirjiiaHLmCAyIOKGlSAieHhiZHh4eGN4Ig==">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>↕</span> <span class='String'>"xxbdxxxcx"</span> ┌─ ╵"xx @@ -32,7 +32,7 @@ <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">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> +<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>) to 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></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> ⟨⟩ @@ -42,7 +42,7 @@ <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> +<p>Adding a <a href="reshape.html#deshape">Deshape</a> gives <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>, which works with the high-rank case discussed below. It tests 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> <h3 id="higher-ranks"><a class="header" href="#higher-ranks">Higher ranks</a></h3> <p>If <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> are two-dimensional then Find does a two-dimensional search. The cells used are also found in <code><span class='Value'>𝕨</span><span class='Function'>≢</span><span class='Modifier2'>⊸</span><span class='Function'>↕</span><span class='Value'>𝕩</span></code>. For example, the bottom-right corner of <code><span class='Value'>𝕩</span></code> below matches <code><span class='Value'>𝕨</span></code>, so there's a 1 in the bottom-right corner of the result.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIGEg4oaQIDcgKDR84ouGy5wp4oyc4peL4oaVIDkgICAjIEFycmF5IHdpdGggcGF0dGVybnMKCigw4oC/M+KAvzDiiY0w4oC/MeKAvzApIOKNtyBh">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>a</span> <span class='Gets'>←</span> <span class='Number'>7</span> <span class='Paren'>(</span><span class='Number'>4</span><span class='Function'>|⋆</span><span class='Modifier'>˜</span><span class='Paren'>)</span><span class='Modifier'>⌜</span><span class='Modifier2'>○</span><span class='Function'>↕</span> <span class='Number'>9</span> <span class='Comment'># Array with patterns @@ -66,7 +66,7 @@ 0 0 1 0 0 0 1 ┘ </pre> -<p>It's also allowed for <code><span class='Value'>𝕨</span></code> to have a smaller rank than <code><span class='Value'>𝕩</span></code>; in this case leading axes of <code><span class='Value'>𝕩</span></code> are mapped over so that axes of <code><span class='Value'>𝕨</span></code> correspond to trailing axes of <code><span class='Value'>𝕩</span></code>. This is a minor violation of the <a href="leading.html">leading axis</a> principle, which would match axes of <code><span class='Value'>𝕨</span></code> to leading axes of <code><span class='Value'>𝕩</span></code> in order to make a function that's useful with the Rank operator, but such a function would be quite strange and hardly ever useful.</p> +<p>It's also allowed for <code><span class='Value'>𝕨</span></code> to have a smaller rank than <code><span class='Value'>𝕩</span></code>; the axes of <code><span class='Value'>𝕨</span></code> then correspond to trailing axes of <code><span class='Value'>𝕩</span></code>, so that leading axes of <code><span class='Value'>𝕩</span></code> are mapped over. This is a minor violation of the <a href="leading.html">leading axis</a> principle, which would match axes of <code><span class='Value'>𝕨</span></code> to leading axes of <code><span class='Value'>𝕩</span></code> in order to make a function that's useful with the Rank operator, but such a function would be quite strange and hardly ever useful.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MOKAvzHigL8w4oC/MSDijbcgYQ==">↗️</a><pre> <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span> <span class='Function'>⍷</span> <span class='Value'>a</span> ┌─ ╵ 0 0 0 0 0 0 |
