diff --git a/doc/array.md b/doc/array.md index 37efa0a0..873778c9 100644 --- a/doc/array.md +++ b/doc/array.md @@ -105,6 +105,8 @@ 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). +An array with no elements (a bound of 0) is called **empty**. These arrays can cause problems when a property should be computed from the elements of an array, like the sum `+´𝕩` or shape of the [merged](couple.md#merge-and-array-theory) array `>𝕩`. BQN has two mechanisms to make these cases work better. First, reductions like `+´` have [identity values](fold.md#identity-values) for certain functions, so that `+´⟨⟩` is `0` for example. Second, every array might have a [fill element](fill.md), a special "typical element" for the array. Functions like Merge use this element's structure to determine the result shape when there are no actual elements to be used. + ## 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. diff --git a/docs/doc/array.html b/docs/doc/array.html index 6ce906e3..ec4eab33 100644 --- a/docs/doc/array.html +++ b/docs/doc/array.html @@ -117,6 +117,7 @@
The total number of elements in an array is its bound, and can be found using Deshape with ≠∘⥊
, or by multiplying all the lengths in the shape. An array of rank 0, which always contains exactly one element, is called a unit, while an array of rank 1 is called a list and an array of rank 2 is called a table.
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.
+An array with no elements (a bound of 0) is called empty. These arrays can cause problems when a property should be computed from the elements of an array, like the sum +´𝕩
or shape of the merged array >𝕩
. BQN has two mechanisms to make these cases work better. First, reductions like +´
have identity values for certain functions, so that +´⟨⟩
is 0
for example. Second, every array might have a fill element, a special "typical element" for the array. Functions like Merge use this element's structure to determine the result shape when there are no actual elements to be used.
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