diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-05-31 21:56:13 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-05-31 21:56:13 -0400 |
| commit | 6078db236e6c34788371576bb51410cf8298b583 (patch) | |
| tree | 0e62588f942289a4fef397b19c5f06c5591f9d1a /doc | |
| parent | f0d58667085fee808a59b9c9e7667ad18d074cdf (diff) | |
Define cells in the documentation
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/array.md | 12 | ||||
| -rw-r--r-- | doc/glossary.md | 8 | ||||
| -rw-r--r-- | doc/rank.md | 4 |
3 files changed, 18 insertions, 6 deletions
diff --git a/doc/array.md b/doc/array.md index 70629cae..37efa0a0 100644 --- a/doc/array.md +++ b/doc/array.md @@ -105,6 +105,18 @@ The total number of elements in an array is its **bound**, and can be found usin Any BQN value can be used as an array element, including another array (BQN, as a dynamically-typed language, doesn't restrict the types that can be used in one context without a good reason). However, BQN arrays are restricted relative to other array models. Frameworks like NumPy or Julia have mutable arrays, so that the value of an element can be changed after the array is created. This allows an array to be its own element, by creating an array and then inserting it into itself. This would be unnatural in BQN, where an array can only be formed from elements that already exist. In BQN only operations and namespaces are [mutable](lexical.md#mutation). +## Cells + +The contents of an array are its elements, but it also makes sense to split up an array into subarrays of elements called cells. The most important kind of cell, a **major cell** consists of all the elements that have indices beginning with some particular index `i`. For this to make sense, `i` must be between `0` and the length `l` of the array's first axis, so that there are `l` major cells each identified by an index. + + 2‿3‿4 ×⌜ 1‿5‿8‿11 + + 1 ⊏ 2‿3‿4 ×⌜ 1‿5‿8‿11 # Major cell 1 + +A major cell still has an array structure: it retains all the axes of the original array other than the first. So it has its own major cells, identified by the index `i` of the original major cell and `j` within it. These are also cells of the original array. Generalizing, a **cell** with index list `l` is defined to be the array of all elements whose indices begin with `l`. In an array with rank `n`, the cell rank is `n-≠l`, and cells grouped using this rank. An `n`-cell mst have an empty cell index, so that it includes all elements—it's the entire array! An `n-1` cell, also called a ¯1-cell, is a major cell. A 0-cell has an index of length `n`, and contains a single element. + +Cells are the center of the [leading axis model](leading.md) used to structure many array primitives. + ## Properties Summarizing, the values needed to define an array are its rank (the number of axes), its shape (the number of positions along each axis), and the value of each element (that is, at each combination of positions). Two arrays [match](match.md) when all these values match. diff --git a/doc/glossary.md b/doc/glossary.md index a25fb5f1..e677c739 100644 --- a/doc/glossary.md +++ b/doc/glossary.md @@ -54,11 +54,11 @@ The possible roles are: * [**Fill**](fill.md): A "prototypical" array element used in certain operations; it's an inferred property of an array. * **Empty**: Having no elements. An array is empty if its shape contains 0. -* **Cell**: An array containing all elements of the original array whose indices share a particular prefix. -* **k-Cell**: A cell of rank *k*. -* [**Major cell**](indices.md#major-cell-indices): A cell with rank one less than the original array. +* [**Cell**](array.md#cells): An array containing all elements of the original array whose indices share a particular prefix. +* [**k-Cell**](array.md#cells): A cell of rank *k*. +* [**Major cell**](array.md#cells): A cell with rank one less than the original array. * [**Agreement**](leading.md#leading-axis-agreement): The way elements are paired when a function maps over two arrays. -* **Frame**: A prefix of an array's shape, used for agreement with the Rank modifier. +* [**Frame**](rank.md#frame-and-cells): A prefix of an array's shape, used for agreement with the Rank modifier. * **Unit**: An array of rank 0, or an atom. * [**Unit array**](enclose.md#whats-a-unit): An array of rank 0. diff --git a/doc/rank.md b/doc/rank.md index fa3e9b68..3bce4c44 100644 --- a/doc/rank.md +++ b/doc/rank.md @@ -65,7 +65,7 @@ The Rank modifier `⎉` generalizes this concept by allowing numbers provided by ## Cells -The function Cells (`˘`) is named after *major cells* in an array. A major cell is a component of an array with dimension one smaller, so that the major cells of a list are [units](enclose.md#whats-a-unit), the major cells of a rank-2 table are its rows (which are lists), and the major cells of a rank-3 array are tables. +The function Cells (`˘`) is named after *major cells* in an array. A [major cell](array.md#cells) is a component of an array with dimension one smaller, so that the major cells of a list are [units](enclose.md#whats-a-unit), the major cells of a rank-2 table are its rows (which are lists), and the major cells of a rank-3 array are tables. The function `𝔽˘` applies `𝔽` to the major cells of `𝕩`. So, for example, where [Nudge](shift.md) (`»`) shifts an entire table, Nudge Cells shifts its major cells, or rows. @@ -115,7 +115,7 @@ The arguments might have different ranks: for example, `"012"` has rank 1 and `a ## Rank -Rank (`⎉`) is a generalization of Cells (`𝔽˘` is defined to be `𝔽⎉¯1`) that can apply to arbitrary—not just major—cells and combine different levels of mapping for two arguments. +Rank (`⎉`) is a generalization of Cells (`𝔽˘` is defined to be `𝔽⎉¯1`) that can apply to arbitrary—not just major—[cells](array.md#cells) and combine different levels of mapping for two arguments. Rank comes in handy when there are high-rank arrays with lots of exciting axes, which is a great use case for BQN but honestly isn't all that common. And to continue this trend of honesty, using Rank just never *feels* good—it's some heavy machinery that I drag out when nothing else works, only to make use of a small part of the functionality. If Cells covers your use cases, that's probably for the best! |
