aboutsummaryrefslogtreecommitdiff
path: root/doc/shape.md
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-07 22:16:01 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-07 22:16:01 -0400
commitbed78fe6147cb7921b7367960d406d28d37cb019 (patch)
tree5fd5f3ad00bfbd66b19aabc4a3d688815754be1e /doc/shape.md
parent07be54d8179ba799cc55dacd2c79fb2292477030 (diff)
The editing is going to end at some point isn't it?
Diffstat (limited to 'doc/shape.md')
-rw-r--r--doc/shape.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/shape.md b/doc/shape.md
index 4c45280f..c597f114 100644
--- a/doc/shape.md
+++ b/doc/shape.md
@@ -2,13 +2,13 @@
# Array dimensions
-The function Shape (`≢`) returns an array's shape, and Rank (`=`) and Length (`≠`) return properties that can be derived from the shape. BQN's arrays are multidimensional, so that the shape is a list of natural numbers (the length along each axis), while the rank (length of the shape) and length (of the first axis) are numbers. In these functions, an atom is treated as a unit array, which has rank 0 and empty shape. A unit has no first axis, but its length is defined to be 1.
+The function Shape (`≢`) returns an array's shape, and Rank (`=`) and Length (`≠`) return properties that can be derived from the shape. BQN's [arrays](array.md) are multidimensional, so that the shape is a list of natural numbers (the length along each axis), while the rank (length of the shape) and length (of the first axis) are numbers. In these functions, an atom is treated as a unit array, which has rank 0 and empty shape. A unit has no first axis, but its length is defined to be 1.
Rank can be defined as `≠∘≢` while Length can be defined with a [fold](fold.md) to be `1⊣´≢`.
## Examples
-The function [Reshape](reshape.md) (`⥊`) always returns an array of shape `𝕨`, so we use it to make an array of shape `1‿3‿2‿6` in the example below ([Take](take.md) (`↑`) shares this property if `(≠𝕨)≤=𝕩`).
+The function [Reshape](reshape.md) (`⥊`) always returns an array of shape `𝕨`, so we use it to make an array of shape `1‿3‿2‿6` in the example below ([Take](take.md) (`↑`) shares this property if `(≠𝕨)≥=𝕩`).
⊢ arr ← 1‿3‿2‿6 ⥊ '0'+↕10
@@ -32,7 +32,7 @@ Applying Shape and the other two functions to an atom shows a shape of `⟨⟩`
## Units
-A unit is an atom, or an array with no axes—rank 0. (See [Enclose](enclose.md) for more about unit arrays). Since it doesn't have any axes, its shape should have no elements. It should be the empty list `⟨⟩` (with a fill of `0`, like all shapes). As there's no first element in the shape, it's not obvious what the length should be, and a stricter language would just give an error. However, there are some good reasons to use a length of `1`. First, the total number of elements is 1, meaning that if the length divides this number evenly (as it does for non-unit arrays) then the only possible natural number it can be is 1. Second, many functions that take a list for a particular argument also accept a unit, and treat it as a length-1 array. For example, `5⥊a` and `⟨5⟩⥊a` are identical. Defining `≠5` to be `1` means that `=s⥊a` is always `≠s`.
+A [unit](enclose.md#whats-a-unit) is an atom, or an array with no axes—rank 0. Since it doesn't have any axes, its shape should have no elements. It should be the empty list `⟨⟩` (with a [fill](fill.md) of `0`, like all shapes). As there's no first element in the shape, it's not obvious what the length should be, and a stricter language would just give an error. However, there are some good reasons to use a length of `1`. First, the total number of elements is 1, meaning that if the length divides this number evenly (as it does for non-unit arrays) then the only possible natural number it can be is 1. Second, many functions that take a list for a particular argument also accept a unit, and treat it as a length-1 array. For example, `5⥊a` and `⟨5⟩⥊a` are identical. Defining `≠5` to be `1` means that `=s⥊a` is always `≠s`.
Despite this last point, it's important to remember that a unit isn't the same as a 1-element list. For example, the length-1 string `"a"` doesn't match `<'a'` but instead `⟨'a'⟩`. And also bear in mind that having an empty *shape* doesn't make a unit an empty *array*. That would mean it has no elements, not one!