diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-06-11 20:08:12 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-06-11 20:08:12 -0400 |
| commit | b6bcf214e638fd36ef7d76c9f573a84e6e016482 (patch) | |
| tree | a435e4f0afed7266b868798e51b792c4600fabe1 /docs/doc/take.html | |
| parent | 383298b70274c5ac22eb2100aad7f6cd8eeca02d (diff) | |
Nothing but edits yet again
Diffstat (limited to 'docs/doc/take.html')
| -rw-r--r-- | docs/doc/take.html | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/docs/doc/take.html b/docs/doc/take.html index 1dd895ff..1c976976 100644 --- a/docs/doc/take.html +++ b/docs/doc/take.html @@ -38,15 +38,16 @@ <li><code><span class='Value'>π©</span></code> can be an atom, or array of any rank (the result will be an array).</li> <li><code><span class='Value'>π¨</span></code> can be negative to take or drop from the end instead of the beginning.</li> <li>For Take, if <code><span class='Value'>π¨</span></code> is larger than the length of <code><span class='Value'>π©</span></code>, then <a href="fill.html">fills</a> are added.</li> -<li><code><span class='Value'>π¨</span></code> can have multiple numbers corresponding to leading axes of <code><span class='Value'>π©</span></code>.</li> +<li><code><span class='Value'>π¨</span></code> can have multiple numbers corresponding to <a href="leading.html">leading</a> axes of <code><span class='Value'>π©</span></code>.</li> <li><code><span class='Value'>π¨</span></code> is allowed to be longer than the rank of <code><span class='Value'>π©</span></code>; <code><span class='Value'>π©</span></code> will be extended to fit.</li> </ul> -<p>These extensions can be combined as well, so there are a lot of possibilities. A good picture to have in mind is cutting out a corner of the array <code><span class='Value'>π©</span></code>. This is because the result <code><span class='Value'>π¨</span><span class='Function'>β</span><span class='Value'>π©</span></code> or <code><span class='Value'>π¨</span><span class='Function'>β</span><span class='Value'>π©</span></code> always aligns with one side of <code><span class='Value'>π©</span></code> along each axis, so it aligns with the corner where those sides meet.</p> +<p>These extensions can be combined as well, so there are a lot of possibilities. A good picture to have in mind is cutting out a corner of the array <code><span class='Value'>π©</span></code>. This is because the result <code><span class='Value'>π¨</span><span class='Function'>β</span><span class='Value'>π©</span></code> or <code><span class='Value'>π¨</span><span class='Function'>β</span><span class='Value'>π©</span></code> always aligns with one side of <code><span class='Value'>π©</span></code> along each axis, so it also aligns with the corner where those sides meet.</p> <p>The result <code><span class='Value'>d</span><span class='Function'>β</span><span class='Value'>π©</span></code> is always the same as <code><span class='Value'>t</span><span class='Function'>β</span><span class='Value'>π©</span></code> for some other argument <code><span class='Value'>t</span></code>, but computing <code><span class='Value'>t</span></code> wouldn't be too convenient. The reverse isn't true: only Take can insert fills, so results that include them can't come from Drop.</p> <h2 id="one-axis"><a class="header" href="#one-axis">One axis</a></h2> -<p>Let's start with a natural number <code><span class='Value'>π¨</span></code>. Take gives the first <code><span class='Value'>π¨</span></code> major cells of <code><span class='Value'>π©</span></code> (or elements of a list), while Drop gives all but the first <code><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=NCDihpEgInRha2UgYW5kIGRyb3AiCjQg4oaTICJ0YWtlIGFuZCBkcm9wIgoKMSDihpMgPiJtYWoi4oC/Im9yYyLigL8iZWxsIg==">βοΈ</a><pre> <span class='Number'>4</span> <span class='Function'>β</span> <span class='String'>"take and drop"</span> +<p>Let's start with a natural number <code><span class='Value'>π¨</span></code>. Take gives the first <code><span class='Value'>π¨</span></code> <a href="array.html#cells">major cells</a> of <code><span class='Value'>π©</span></code> (or elements of a list), while Drop gives all but the first <code><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=NCDihpEgInRha2UgYW5kIGRyb3AiCgo0IOKGkyAidGFrZSBhbmQgZHJvcCIKCjEg4oaTID4ibWFqIuKAvyJvcmMi4oC/ImVsbCI=">βοΈ</a><pre> <span class='Number'>4</span> <span class='Function'>β</span> <span class='String'>"take and drop"</span> "take" + <span class='Number'>4</span> <span class='Function'>β</span> <span class='String'>"take and drop"</span> " and drop" @@ -77,7 +78,7 @@ β¨β© </pre> <h3 id="negative-argument"><a class="header" href="#negative-argument">Negative argument</a></h3> -<p>If <code><span class='Value'>π¨</span></code> is negative then wraps around the other side to take or drop from the end of <code><span class='Value'>π©</span></code>. It's a lot like negative indices in <a href="select.html">Select</a> (<code><span class='Function'>β</span></code>), but while negative indices are asymmetricβ<code><span class='Number'>0</span></code> is the first entry but <code><span class='Number'>Β―1</span></code> is the lastβthis case is symmetric. It's because the place to cut is always <em>before</em> the index <code><span class='Value'>π¨</span></code>, cancelling out the negative index asymmetry.</p> +<p>If <code><span class='Value'>π¨</span></code> is negative, it wraps around the other side to take or drop from the end of <code><span class='Value'>π©</span></code>. It's a lot like negative indices in <a href="select.html">Select</a> (<code><span class='Function'>β</span></code>), but while negative indices are asymmetricβ<code><span class='Number'>0</span></code> is the first entry but <code><span class='Number'>Β―1</span></code> is the lastβthis case is symmetric. It's because the place to cut is always <em>before</em> the index <code><span class='Value'>π¨</span></code>, cancelling out the negative index asymmetry.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MyDihpEgImFiY2RlRURDQkEiCgrCrzMg4oaRICJhYmNkZUVEQ0JBIiAgIyBMYXN0IHRocmVlCgrCrzMg4oaTICJhYmNkZUVEQ0JBIiAgIyBBbGwgYnV0IHRoZSBsYXN0IHRocmVl">βοΈ</a><pre> <span class='Number'>3</span> <span class='Function'>β</span> <span class='String'>"abcdeEDCBA"</span> "abc" @@ -94,12 +95,12 @@ <span class='Number'>0</span> <span class='Function'>β</span> <span class='Number'>4</span><span class='Ligature'>βΏ</span><span class='Number'>3</span><span class='Ligature'>βΏ</span><span class='Number'>2</span> <span class='Comment'># Everything </span>β¨ 4 3 2 β© </pre> -<p>If <code><span class='Function'>|</span><span class='Value'>π¨</span></code> is too large, then Take will insert fills at the beginning to keep the result aligned with <code><span class='Value'>π©</span></code> at the end. Drop returns an empty array as in the positive case. So unlike <a href="reverse.html">Rotate</a> (<code><span class='Function'>β½</span></code>), which is completely cyclical, Take and Drop work cyclically only around 0.</p> +<p>If <code><span class='Function'>|</span><span class='Value'>π¨</span></code> is too large, then Take will insert fills at the beginning to keep the result aligned with <code><span class='Value'>π©</span></code> at the end. Drop returns an empty array as in the positive case. So unlike <a href="reverse.html">Rotate</a> (<code><span class='Function'>β½</span></code>), which is completely cyclical, Take and Drop look cyclic only around 0.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=wq82IOKGkSAieHki">βοΈ</a><pre> <span class='Number'>Β―6</span> <span class='Function'>β</span> <span class='String'>"xy"</span> " xy" </pre> <h2 id="multiple-axes"><a class="header" href="#multiple-axes">Multiple axes</a></h2> -<p>In the general case <code><span class='Value'>π¨</span></code> is a list of integers. They're matched with the leading axes of <code><span class='Value'>π©</span></code>, so that each affects one axis independently from the others.</p> +<p>In the general case <code><span class='Value'>π¨</span></code> is a list of integers. They're matched with the <a href="leading.html">leading axes</a> of <code><span class='Value'>π©</span></code>, so that each affects one axis independently from the others.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIG0g4oaQICgxMMOX4oaVNSkgK+KMnCDihpU3CgrCrzTigL8yIOKGkSBtICAjIExhc3QgZm91ciByb3dzOyBmaXJzdCB0d28gY29sdW1ucwoKwq804oC/MiDihpMgbQ==">βοΈ</a><pre> <span class='Function'>β’</span> <span class='Value'>m</span> <span class='Gets'>β</span> <span class='Paren'>(</span><span class='Number'>10</span><span class='Function'>Γβ</span><span class='Number'>5</span><span class='Paren'>)</span> <span class='Function'>+</span><span class='Modifier'>β</span> <span class='Function'>β</span><span class='Number'>7</span> ββ β΅ 0 1 2 3 4 5 6 |
