diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-07-16 18:23:52 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-07-16 18:24:01 -0400 |
| commit | 2010e8b2897a5741e211980c9f8ec9177299c939 (patch) | |
| tree | 4b3476744be928724da2fd5d83b0bf2e9a8ba502 /docs/doc/reverse.html | |
| parent | e3366f9e18a8791c43110e080b9ea45cfceefed8 (diff) | |
Finish links and editing documentation pass
Diffstat (limited to 'docs/doc/reverse.html')
| -rw-r--r-- | docs/doc/reverse.html | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/doc/reverse.html b/docs/doc/reverse.html index edcb37a7..62eae902 100644 --- a/docs/doc/reverse.html +++ b/docs/doc/reverse.html @@ -5,7 +5,7 @@ </head> <div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a> / <a href="../index.html">main</a> / <a href="index.html">doc</a></div> <h1 id="reverse-and-rotate">Reverse and Rotate</h1> -<p>The symbol <code><span class='Function'>⌽</span></code> indicates two different array transformations: with no left argument, it reverses the major cells of the array, but with a left argument, it rotates or cycles them around. These two possibilities, first put together in very early versions of APL, can't be considered restrictions or different views of some unifying function, but there are connections between them. Each returns an array with the same shape and all the same elements as <code><span class='Value'>𝕩</span></code>, possibly in a different arrangement. And elements that start out next to each other in <code><span class='Value'>𝕩</span></code> generally stay next to each other—always, if we consider an element on one edge to be next to the one opposite to it. One might think of them as <a href="https://en.wikipedia.org/wiki/Isometry">isometries</a> preserving a discrete subgroup of the torus, if one were inclined to think such things. On major cells, the two functions decompose the <a href="https://en.wikipedia.org/wiki/Dihedral_group">dihedral group</a> okay I'll stop.</p> +<p>The symbol <code><span class='Function'>⌽</span></code> indicates two different array transformations: with no left argument, it reverses the major cells of the array, but with a left argument, it rotates or cycles them around. These two possibilities, first put together in very early versions of APL, can't be considered restrictions or different views of some unifying function, but there are connections between them. Each returns an array with the same <a href="shape.html">shape</a> and all the same elements as <code><span class='Value'>𝕩</span></code>, possibly in a different arrangement. And elements that start out next to each other in <code><span class='Value'>𝕩</span></code> generally stay next to each other—always, if we consider an element on one edge to be next to the one opposite to it. One might think of them as <a href="https://en.wikipedia.org/wiki/Isometry">isometries</a> preserving a discrete subgroup of the torus, if one were inclined to think such things. On major cells, the two functions decompose the <a href="https://en.wikipedia.org/wiki/Dihedral_group">dihedral group</a> okay I'll stop.</p> <p>Many uses of Rotate in APL are better handled by <a href="shift.html">shift</a> functions in BQN. If there's no reason to treat the data as cyclic or periodic, it's best to avoid Rotate.</p> <h2 id="reverse">Reverse</h2> <p>There's not too much to say about Reverse. It puts the elements of a list the other way around, or more generally the major cells of an array.</p> @@ -46,7 +46,7 @@ ⟨ 1 1 1 1 1 1 0 ⟩ </pre> <h2 id="rotate">Rotate</h2> -<p>Rotate moves elements in a list around cyclically. It can also rotate any number of axes of the argument array by different amounts at once. That's discussed in the next section; for now we'll stick to a single number in the left argument. It has to be an integer, and the right argument has to be an array with at least one axis.</p> +<p>Rotate moves elements in a list around cyclically. It can also rotate any number of axes of the argument array by different amounts at once. That's discussed in the next section; for now we'll stick to a single number for <code><span class='Value'>𝕨</span></code>. It has to be an integer, and <code><span class='Value'>𝕩</span></code> has to be an array with at least one axis.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDijL0gInJvdGF0ZSIKCjIgKOKKoiDiiY3il4s8IOKMvSkgNeKAvzLipYoicm90YXRlQ0VMTCIKCjIg4oy9ICdjJyAgIyBObyBheGVzIHRvIHJvdGF0ZQ==">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>⌽</span> <span class='String'>"rotate"</span> "tatero" @@ -64,12 +64,12 @@ <span class='Number'>2</span> <span class='Function'>⌽</span> <span class='String'>'c'</span> <span class='Comment'># No axes to rotate </span>ERROR </pre> -<p>Elements are always rotated to the left, so that entry <code><span class='Value'>i</span></code> of the result is entry <code><span class='Value'>𝕨</span><span class='Function'>+</span><span class='Value'>i</span></code> of the argument—or rather, entry <code><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>|</span><span class='Value'>𝕨</span><span class='Function'>+</span><span class='Value'>i</span></code> to enable elements to cycle around. This can be seen directly by using <code><span class='Function'>↕</span><span class='Value'>n</span></code> as an argument: in this case, the value of <code><span class='Value'>𝕩</span></code> at index <code><span class='Value'>i</span></code> is just <code><span class='Value'>i</span></code>.</p> +<p>Elements are always rotated to the left, so that entry <code><span class='Value'>i</span></code> of the result is entry <code><span class='Value'>𝕨</span><span class='Function'>+</span><span class='Value'>i</span></code> of the argument—or rather, entry <code><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>|</span><span class='Value'>𝕨</span><span class='Function'>+</span><span class='Value'>i</span></code> to enable elements to cycle around. This can be seen directly by using the <a href="range.html">range</a> <code><span class='Function'>↕</span><span class='Value'>n</span></code> as an argument: then the value of <code><span class='Value'>𝕩</span></code> at index <code><span class='Value'>i</span></code> is just <code><span class='Value'>i</span></code>.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDijL0g4oaVNg==">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>⌽</span> <span class='Function'>↕</span><span class='Number'>6</span> ⟨ 2 3 4 5 0 1 ⟩ </pre> -<p>The rotation <code><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>⌽</span><span class='Value'>𝕩</span></code> moves each element the entire length of <code><span class='Value'>𝕩</span></code>, which just places it back where it started. In fact, adding <code><span class='Function'>≠</span><span class='Value'>𝕩</span></code> to the rotation amount never changes the behavior or the rotation. In terms of indices, this is because <code><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>|</span><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Value'>a</span></code> is <code><span class='Value'>a</span></code>.</p> -<p>To rotate the other way, use a negative left argument (so <code><span class='Function'>-</span><span class='Modifier2'>⊸</span><span class='Function'>⌽</span></code> is a simple way to write "reverse rotate"). This will always be the same as a leftwards rotation, since <code><span class='Paren'>(</span><span class='Function'>-</span><span class='Value'>r</span><span class='Paren'>)</span><span class='Function'>⌽</span><span class='Value'>𝕩</span></code> is <code><span class='Paren'>((</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>-</span><span class='Value'>r</span><span class='Paren'>)</span><span class='Function'>⌽</span><span class='Value'>𝕩</span></code>, but could be more convenient.</p> +<p>The rotation <code><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>⌽</span><span class='Value'>𝕩</span></code> moves each element the entire <a href="shape.html">length</a> of <code><span class='Value'>𝕩</span></code>, which just places it back where it started. In fact, adding <code><span class='Function'>≠</span><span class='Value'>𝕩</span></code> to the rotation amount never changes the behavior or the rotation. In terms of indices, this is because <code><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>|</span><span class='Paren'>(</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Value'>a</span></code> is <code><span class='Value'>a</span></code>.</p> +<p>To rotate the other way, use a negative left argument (so <code><span class='Function'>-</span><span class='Modifier2'>⊸</span><span class='Function'>⌽</span></code> is a simple way to write "reverse rotate"). This will always be the same as some leftwards rotation, since <code><span class='Paren'>(</span><span class='Function'>-</span><span class='Value'>r</span><span class='Paren'>)</span><span class='Function'>⌽</span><span class='Value'>𝕩</span></code> is <code><span class='Paren'>((</span><span class='Function'>≠</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>-</span><span class='Value'>r</span><span class='Paren'>)</span><span class='Function'>⌽</span><span class='Value'>𝕩</span></code>, but could be more convenient.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=wq8yIOKMvSAicm90YXRlIg==">↗️</a><pre> <span class='Number'>¯2</span> <span class='Function'>⌽</span> <span class='String'>"rotate"</span> "terota" </pre> |
