From 228e1b6d9d60eb885e5cda1b2c05048b253e140d Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 4 Jul 2021 22:34:44 -0400 Subject: Diagram and introduction for search functions --- doc/search.md | 51 +++++++++++++++++++++ docs/doc/search.html | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 doc/search.md create mode 100644 docs/doc/search.html diff --git a/doc/search.md b/doc/search.md new file mode 100644 index 00000000..a71b0676 --- /dev/null +++ b/doc/search.md @@ -0,0 +1,51 @@ +*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/doc/search.html).* + +# Search functions + + + +The three search functions are Index of (`⊐`), Progressive Index of (`⊒`), and Member of (`∊`). These are dyadic functions that search one argument ("searched-in") for major cells [matching](match.md) cells from the other ("searched-for"). For example, Index of returns, for each cell in `𝕩`, the index of the first cell in `𝕨` that matches it. + +| | Name | for | in | Return +|:----:|-----------------------|:---:|:---:|------- +| `⊐` | Index of | `𝕩` | `𝕨` | Index of first match +| `⊒` | Progressive Index of | `𝕩` | `𝕨` | Index of first unused match +| `∊` | Member of | `𝕨` | `𝕩` | `1` if found, `0` if not +| `⍋⍒` | [Bins](order.md#bins) | `𝕩` | `𝕨` | Predecessor index + +The searched-for argument is `𝕩` in Index-of functions (`⊐⊒`) and `𝕨` in Member of (`∊`). [Bins](order.md#bins) Up and Down (`⍋⍒`) are ordering functions but follow the same pattern as Index-of. It's split into cells, but not necessarily *major* 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). + +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. diff --git a/docs/doc/search.html b/docs/doc/search.html new file mode 100644 index 00000000..118cd35a --- /dev/null +++ b/docs/doc/search.html @@ -0,0 +1,126 @@ + + + + BQN: Search functions + + +

Search functions

+ + + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + 's' + 'e' + 'a' + 'r' + 'c' + 'h' + 'e' + 's' + 'e' + 's' + 's' + 'a' + 'y' + 's' + 1 + 0 + 0 + 2 + 8 + 0 + 1 + 0 + 7 + 2 + 8 + 8 + 1 + 1 + 1 + 1 + 0 + 1 + + in + for + + + + + + + +

The three search functions are Index of (), Progressive Index of (), and Member of (). These are dyadic functions that search one argument ("searched-in") for major cells matching cells from the other ("searched-for"). For example, Index of returns, for each cell in 𝕩, the index of the first cell in 𝕨 that matches it.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameforinReturn
Index of𝕩𝕨Index of first match
Progressive Index of𝕩𝕨Index of first unused match
Member of𝕨𝕩1 if found, 0 if not
⍋⍒Bins𝕩𝕨Predecessor index
+

The searched-for argument is 𝕩 in Index-of functions (⊐⊒) and 𝕨 in Member of (). Bins Up and Down (⍋⍒) are ordering functions but follow the same pattern as Index-of. It's split into cells, but not necessarily major 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).

+

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.

-- cgit v1.2.3