diff options
Diffstat (limited to 'docs/doc/replicate.html')
| -rw-r--r-- | docs/doc/replicate.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/doc/replicate.html b/docs/doc/replicate.html index 2f81bce5..746062ea 100644 --- a/docs/doc/replicate.html +++ b/docs/doc/replicate.html @@ -157,7 +157,7 @@ 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 ┘ </pre> -<p>Above, both elements of <code><span class='Value'>𝕨</span></code> are enclosed numbers. An individual element doesn't have to be enclosed, but I don't recommend this, since if <em>none</em> of them are enclosed, then <code><span class='Value'>𝕨</span></code> will have depth 1 and it will be interpreted as replicating along the first axis only.</p> +<p>Above, both elements of <code><span class='Value'>𝕨</span></code> are <a href="enclose.html">enclosed</a> numbers. An individual element doesn't have to be enclosed, but I don't recommend this, since if <em>none</em> of them are enclosed, then <code><span class='Value'>𝕨</span></code> will have depth 1 and it will be interpreted as replicating along the first axis only.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oMiwz4p+pIC8gYg==">↗️</a><pre> <span class='Bracket'>⟨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>3</span><span class='Bracket'>⟩</span> <span class='Function'>/</span> <span class='Value'>b</span> ┌─ ╵ 0 1 2 3 4 @@ -173,7 +173,7 @@ 1 </pre> <h2 id="indices">Indices</h2> -<p>The monadic form of <code><span class='Function'>/</span></code> is much simpler than the dyadic one, with no multidimensional case or mismatched argument ranks. <code><span class='Value'>𝕩</span></code> must be a list of natural numbers, and <code><span class='Function'>/</span><span class='Value'>𝕩</span></code> is the list <code><span class='Value'>𝕩</span><span class='Function'>/↕≠</span><span class='Value'>𝕩</span></code>. Its elements are the indices for <code><span class='Value'>𝕩</span></code>, with index <code><span class='Value'>i</span></code> repeated <code><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>𝕩</span></code> times.</p> +<p>The monadic form of <code><span class='Function'>/</span></code> is much simpler than the dyadic one, with no multidimensional case or mismatched argument ranks. <code><span class='Value'>𝕩</span></code> must be a list of natural numbers, and <code><span class='Function'>/</span><span class='Value'>𝕩</span></code> is the list <code><span class='Value'>𝕩</span><span class='Function'>/↕≠</span><span class='Value'>𝕩</span></code>. Its elements are the <a href="indices.html">indices</a> for <code><span class='Value'>𝕩</span></code>, with index <code><span class='Value'>i</span></code> repeated <code><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>𝕩</span></code> times.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=LyAz4oC/MOKAvzHigL8y">↗️</a><pre> <span class='Function'>/</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span> ⟨ 0 0 0 2 3 3 ⟩ </pre> @@ -183,14 +183,14 @@ ⟨ "AB" "CDEFG" ⟨⟩ "H" ⟩ </pre> <p>This function will fail to include trailing empty arrays; the modification <code><span class='Paren'>(</span><span class='Function'>/∾</span><span class='Modifier2'>⟜</span><span class='Number'>1</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>⊔</span></code> fixes this and ensures the result always has as many elements as <code><span class='Value'>𝕨</span></code>.</p> -<p>If <code><span class='Value'>𝕩</span></code> is boolean then <code><span class='Function'>/</span><span class='Value'>𝕩</span></code> contains all the indices where a 1 appears in <code><span class='Value'>𝕩</span></code>. Applying <code><span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Function'>»</span></code> to the result gives the distance from each 1 to the previous, or to the start of the list, another potentially useful function.</p> +<p>If <code><span class='Value'>𝕩</span></code> is boolean then <code><span class='Function'>/</span><span class='Value'>𝕩</span></code> contains all the indices where a 1 appears in <code><span class='Value'>𝕩</span></code>. Applying <code><span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Function'>»</span></code> to the result gives the distance from each 1 to the <a href="shift.html">previous</a>, or to the start of the list, another potentially useful function.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=LyAw4oC/MeKAvzDigL8x4oC/MOKAvzDigL8w4oC/MOKAvzHigL8wCgot4p+cwrsgLyAw4oC/MeKAvzDigL8x4oC/MOKAvzDigL8w4oC/MOKAvzHigL8w">↗️</a><pre> <span class='Function'>/</span> <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='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>0</span> ⟨ 1 3 8 ⟩ <span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Function'>»</span> <span class='Function'>/</span> <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='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>0</span> ⟨ 1 2 5 ⟩ </pre> -<p>With more effort we can also use <code><span class='Function'>/</span></code> to analyze groups of 1s in the argument (and of course all these methods can be applied to 0s instead, by first flipping the values with <code><span class='Function'>¬</span></code>). First we highlight the start and end of each group by comparing the list with a shifted copy of itself. Or rather, we'll first place a 0 at the front and then at the end, in order to detect when a group starts at the beginning of the list or ends at the end (there's also a <a href="shift.html">shift</a>-based version, <code><span class='Function'>≠</span><span class='Modifier2'>⟜</span><span class='Function'>«</span><span class='Number'>0</span><span class='Function'>∾</span><span class='Value'>𝕩</span></code>).</p> +<p>With more effort we can also use <code><span class='Function'>/</span></code> to analyze groups of 1s in the argument (and of course all these methods can be applied to 0s instead, by first flipping the values with <code><span class='Function'>¬</span></code>). First we highlight the start and end of each group by comparing the list with a shifted copy of itself. Or rather, we'll first place a 0 at the front and then at the end, in order to detect when a group starts at the beginning of the list or ends at the end (there's also a shift-based version, <code><span class='Function'>≠</span><span class='Modifier2'>⟜</span><span class='Function'>«</span><span class='Number'>0</span><span class='Function'>∾</span><span class='Value'>𝕩</span></code>).</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MCAo4oi+4omN4oi+y5wpIDDigL8x4oC/MeKAvzHigL8w4oC/MOKAvzHigL8w4oC/MeKAvzHigL8wCgowICjiiL7iiaDiiL7LnCkgMOKAvzHigL8x4oC/MeKAvzDigL8w4oC/MeKAvzDigL8x4oC/MeKAvzAKCi8gMCjiiL7iiaDiiL7LnCkgMOKAvzHigL8x4oC/MeKAvzDigL8w4oC/MeKAvzDigL8x4oC/MeKAvzA=">↗️</a><pre> <span class='Number'>0</span> <span class='Paren'>(</span><span class='Function'>∾≍∾</span><span class='Modifier'>˜</span><span class='Paren'>)</span> <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>1</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'>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='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>0</span> ┌─ ╵ 0 0 1 1 1 0 0 1 0 1 1 0 |
