diff options
Diffstat (limited to 'docs/doc/pick.html')
| -rw-r--r-- | docs/doc/pick.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/doc/pick.html b/docs/doc/pick.html index 76f9bfe9..d3166012 100644 --- a/docs/doc/pick.html +++ b/docs/doc/pick.html @@ -4,11 +4,11 @@ <title>BQN: Pick</title> </head> <div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">doc</a></div> -<h1 id="pick">Pick</h1> +<h1 id="pick"><a class="header" href="#pick">Pick</a></h1> <p>Pick (<code><span class='Function'>โ</span></code>) chooses elements from <code><span class='Value'>๐ฉ</span></code> based on <a href="indices.html">index</a> lists from <code><span class='Value'>๐จ</span></code>. <code><span class='Value'>๐จ</span></code> can be a plain list, or even one number if <code><span class='Value'>๐ฉ</span></code> is a list, in order to get one element from <code><span class='Value'>๐ฉ</span></code>. It can also be an array of index lists, or have deeper array structure: each index list will be replaced with the element of <code><span class='Value'>๐ฉ</span></code> at that index, effectively applying to <code><span class='Value'>๐จ</span></code> at <a href="depth.html#the-depth-modifier">depth</a> 1.</p> <p>With no <code><span class='Value'>๐จ</span></code>, monadic <code><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code> takes the first element of <code><span class='Value'>๐ฉ</span></code> in index order, with an error if <code><span class='Value'>๐ฉ</span></code> is empty.</p> <p>While sometimes "scatter-point" indexing is necessary, using Pick to select multiple elements from <code><span class='Value'>๐ฉ</span></code> is less array-oriented than <a href="select.html">Select</a> (<code><span class='Function'>โ</span></code>), and probably slower. Consider rearranging your data so that you can select along axes instead of picking out elements.</p> -<h2 id="one-element">One element</h2> +<h2 id="one-element"><a class="header" href="#one-element">One element</a></h2> <p>When the left argument is a number, Pick gets an element from a list:</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDiipEgMOKAvzHigL8y4oC/M+KAvzQKMiDiipEgImFiYyIKMiDiipEg4p+oQCwgMOKAvzHigL8y4oC/MywgImFiYyLin6k=">โ๏ธ</a><pre> <span class='Number'>2</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'>2</span><span class='Ligature'>โฟ</span><span class='Number'>3</span><span class='Ligature'>โฟ</span><span class='Number'>4</span> 2 @@ -46,7 +46,7 @@ <span class='Bracket'>โจโฉ</span> <span class='Function'>โ</span> <span class='String'>'a'</span> 'a' </pre> -<h3 id="first">First</h3> +<h3 id="first"><a class="header" href="#first">First</a></h3> <p>With no left argument, <code><span class='Function'>โ</span></code> is called First, and performs a slight generalization of Pick with a default left argument <code><span class='Number'>0</span><span class='Modifier'>ยจ</span><span class='Function'>โข</span><span class='Value'>๐ฉ</span></code>. For a non-empty array it returns the first element in index order.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRIDwnYScK4oqRICJGaXJzdCIK4oqRIOKGlTTigL8y4oC/NeKAvzE=">โ๏ธ</a><pre> <span class='Function'>โ</span> <span class='Function'><</span><span class='String'>'a'</span> 'a' @@ -69,7 +69,7 @@ ERROR <span class='Function'>โข</span><span class='Modifier'>ยด</span> <span class='String'>"last"</span> 't' </pre> -<h2 id="many-elements">Many elements</h2> +<h2 id="many-elements"><a class="header" href="#many-elements">Many elements</a></h2> <p>Pick also accepts a list of indices:</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YSAgIyBEZWZpbmVkIGFib3ZlCgrin6gy4oC/MCwgMeKAv8KvMSwgM+KAvzEsIMKvMeKAv8KvMeKfqSDiipEgYQ==">โ๏ธ</a><pre> <span class='Value'>a</span> <span class='Comment'># Defined above </span>โโ |
