diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-08-11 17:21:31 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-08-11 17:25:04 -0400 |
| commit | 2afb23928e1984d475cc460e1672e8f6fa0e4dbe (patch) | |
| tree | ebd2cc514294d30b6fa4b36c2ee638326f06ef72 /docs/doc/search.html | |
| parent | eac61ca02074c218667754d5f4ef562e780bae85 (diff) | |
Allow clicking on header to get fragment link
Diffstat (limited to 'docs/doc/search.html')
| -rw-r--r-- | docs/doc/search.html | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/doc/search.html b/docs/doc/search.html index accd54fa..7834a06d 100644 --- a/docs/doc/search.html +++ b/docs/doc/search.html @@ -4,7 +4,7 @@ <title>BQN: Search functions</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="search-functions">Search functions</h1> +<h1 id="search-functions"><a class="header" href="#search-functions">Search functions</a></h1> <svg viewBox='-124.8 -46.8 532.8 280.8'> <defs> <mask id='m'> @@ -133,7 +133,7 @@ </table> <p>The searched-for argument is <code><span class='Value'>𝕩</span></code> in Index-of functions (<code><span class='Function'>⊐⊒</span></code>) and <code><span class='Value'>𝕨</span></code> in Member of (<code><span class='Function'>∊</span></code>). <a href="order.html#bins">Bins</a> Up and Down (<code><span class='Function'>⍋⍒</span></code>) are ordering functions but follow the same pattern as Index-of. It's split into cells, but not necessarily <em>major</em> cells: instead, the cells used match the rank of a major cell of the other (searched-in) argument. In the most common case, when the searched-in argument is a list, 0-cells are used for the search (we might also say elements, as it gives the same result).</p> <p>The result is always an array containing one number for each searched-for cell. For Index of and Member of, every result is computed independently; for Progressive Index of the result for a cell can depend on earlier cells, in index order.</p> -<h2 id="member-of">Member of</h2> +<h2 id="member-of"><a class="header" href="#member-of">Member of</a></h2> <p>The simplest of the search functions, Member of (<code><span class='Function'>∊</span></code>) returns <code><span class='Number'>1</span></code> if an entry in <code><span class='Value'>𝕨</span></code> matches some entry in <code><span class='Value'>𝕩</span></code>, and <code><span class='Number'>0</span></code> if it doesn't.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ImdyZWVuIuKAvyJicmlja3Mi4oC/ImNvdyLigL8iYmx1ZSIg4oiKICJyZWQi4oC/ImdyZWVuIuKAvyJibHVlIg==">↗️</a><pre> <span class='String'>"green"</span><span class='Ligature'>‿</span><span class='String'>"bricks"</span><span class='Ligature'>‿</span><span class='String'>"cow"</span><span class='Ligature'>‿</span><span class='String'>"blue"</span> <span class='Function'>∊</span> <span class='String'>"red"</span><span class='Ligature'>‿</span><span class='String'>"green"</span><span class='Ligature'>‿</span><span class='String'>"blue"</span> ⟨ 1 0 0 1 ⟩ @@ -147,7 +147,7 @@ </span>"tal st" </pre> <p>These are the APL functions Intersect (<code><span class='Value'>∩</span></code>) and Without (<code><span class='Value'>~</span></code>). Really, only <code><span class='Value'>𝕩</span></code> is treated like a set, while the ordering and multiplicity of elements of <code><span class='Value'>𝕨</span></code> are maintained. I think the explicit implementations show this well, since <code><span class='Value'>𝕩</span></code> is only used as the right argument to <code><span class='Function'>∊</span></code>, and prefer this clarity to the brevity of a single symbol.</p> -<h2 id="index-of">Index of</h2> +<h2 id="index-of"><a class="header" href="#index-of">Index of</a></h2> <p>Index of (<code><span class='Function'>⊐</span></code>) returns the index of the first occurrence of each entry in <code><span class='Value'>𝕨</span></code>, or <code><span class='Function'>≠</span><span class='Value'>𝕨</span></code> if an entry doesn't appear in <code><span class='Value'>𝕨</span></code> at all.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Inplcm8i4oC/Im9uZSLigL8idHdvIuKAvyJ0aHJlZSIg4oqQICJvbmUi4oC/ImVpZ2h0IuKAvyJ0d28i">↗️</a><pre> <span class='String'>"zero"</span><span class='Ligature'>‿</span><span class='String'>"one"</span><span class='Ligature'>‿</span><span class='String'>"two"</span><span class='Ligature'>‿</span><span class='String'>"three"</span> <span class='Function'>⊐</span> <span class='String'>"one"</span><span class='Ligature'>‿</span><span class='String'>"eight"</span><span class='Ligature'>‿</span><span class='String'>"two"</span> ⟨ 1 4 2 ⟩ @@ -160,7 +160,7 @@ <span class='String'>"letters"</span> <span class='Paren'>(</span><span class='Function'><</span><span class='Modifier2'>∘</span><span class='Function'>/</span><span class='Modifier'>˘</span><span class='Function'>≡</span><span class='Modifier'>⌜˜</span><span class='Paren'>)</span> <span class='String'>"let"</span> <span class='Comment'># Many to many </span>⟨ ⟨ 0 ⟩ ⟨ 1 4 ⟩ ⟨ 2 3 ⟩ ⟩ </pre> -<h2 id="progressive-index-of">Progressive Index of</h2> +<h2 id="progressive-index-of"><a class="header" href="#progressive-index-of">Progressive Index of</a></h2> <p>Progressive Index of (<code><span class='Function'>⊒</span></code>), as the name and glyph suggest, is a more sophisticated variant of Index of. Like Index of, it returns either <code><span class='Function'>≠</span><span class='Value'>𝕨</span></code> or an index of a cell from <code><span class='Value'>𝕨</span></code> that matches the given cell of <code><span class='Value'>𝕩</span></code>. Unlike Index of, no index except <code><span class='Function'>≠</span><span class='Value'>𝕨</span></code> can ever be repeated. Progressive Index of returns the index of the first <em>unused</em> match, provided there's still one left.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ImFhYSIg4oqSICJhYWFhYSIKCiJhYWFiYiIg4oqSICJhYmFiYWJhYmFiIg==">↗️</a><pre> <span class='String'>"aaa"</span> <span class='Function'>⊒</span> <span class='String'>"aaaaa"</span> ⟨ 0 1 2 3 3 ⟩ @@ -192,7 +192,7 @@ <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqSy5wgImFueXRoaW5nIGF0IGFsbCI=">↗️</a><pre> <span class='Function'>⊒</span><span class='Modifier'>˜</span> <span class='String'>"anything at all"</span> ⟨ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ⟩ </pre> -<h2 id="single-search">Single search</h2> +<h2 id="single-search"><a class="header" href="#single-search">Single search</a></h2> <p>Search functions are designed to search for multiple elements at once, and return an array of results. This is the array-oriented way to do it, and can allow faster algorithms to be used for the computation.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=c3R1ZmYg4oaQICJ0YWNrcyLigL8icGFwZXIi4oC/InN0cmluZyLigL8idGFwZSIKCnN0dWZmIOKKkCAidGFja3Mi4oC/InN0cmluZyI=">↗️</a><pre> <span class='Value'>stuff</span> <span class='Gets'>←</span> <span class='String'>"tacks"</span><span class='Ligature'>‿</span><span class='String'>"paper"</span><span class='Ligature'>‿</span><span class='String'>"string"</span><span class='Ligature'>‿</span><span class='String'>"tape"</span> @@ -218,7 +218,7 @@ 2 </pre> <p>For Member of, the equivalent is <code><span class='Function'>∊</span><span class='Modifier2'>⟜</span><span class='Value'>stuff</span><span class='Modifier2'>⌾</span><span class='Function'><</span></code>.</p> -<h2 id="higher-ranks">Higher ranks</h2> +<h2 id="higher-ranks"><a class="header" href="#higher-ranks">Higher ranks</a></h2> <p>So far we've shown search functions acting on lists. Well, and one example with a unit array slipped into the last section. In fact, if the searched-in array is a list, then the searched-for argument can have any rank.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KCJoaWdoIuKJjSJyYW5rIikg4oiKICJsaXN0IGFyZyI=">↗️</a><pre> <span class='Paren'>(</span><span class='String'>"high"</span><span class='Function'>≍</span><span class='String'>"rank"</span><span class='Paren'>)</span> <span class='Function'>∊</span> <span class='String'>"list arg"</span> ┌─ |
