diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-06-04 16:03:55 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-06-04 16:03:55 -0400 |
| commit | cd0f461eee93367459dd82a29dd148fff75e5ec6 (patch) | |
| tree | 3983f1e5e58a4374baaf7abfca8e62dcdf9fc705 /docs/doc/array.html | |
| parent | efa9759b24567bdda8f6345bd4b6e548e8a278cc (diff) | |
Paragraph about empty arrays
Diffstat (limited to 'docs/doc/array.html')
| -rw-r--r-- | docs/doc/array.html | 1 |
1 files changed, 1 insertions, 0 deletions
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 @@ <p>The total number of elements in an array is its <strong>bound</strong>, and can be found using <a href="reshape.html">Deshape</a> with <code><span class='Function'>≠</span><span class='Modifier2'>∘</span><span class='Function'>⥊</span></code>, or by multiplying all the lengths in the shape. An array of rank 0, which always contains exactly one element, is called a <a href="enclose.html#whats-a-unit"><strong>unit</strong></a>, while an array of rank 1 is called a <strong>list</strong> and an array of rank 2 is called a <strong>table</strong>.</p> <h2 id="elements"><a class="header" href="#elements">Elements</a></h2> <p>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 <a href="lexical.html#mutation">mutable</a>.</p> +<p>An array with no elements (a bound of 0) is called <strong>empty</strong>. These arrays can cause problems when a property should be computed from the elements of an array, like the sum <code><span class='Function'>+</span><span class='Modifier'>´</span><span class='Value'>𝕩</span></code> or shape of the <a href="couple.html#merge-and-array-theory">merged</a> array <code><span class='Function'>></span><span class='Value'>𝕩</span></code>. BQN has two mechanisms to make these cases work better. First, reductions like <code><span class='Function'>+</span><span class='Modifier'>´</span></code> have <a href="fold.html#identity-values">identity values</a> for certain functions, so that <code><span class='Function'>+</span><span class='Modifier'>´</span><span class='Bracket'>⟨⟩</span></code> is <code><span class='Number'>0</span></code> for example. Second, every array might have a <a href="fill.html">fill element</a>, 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.</p> <h2 id="cells"><a class="header" href="#cells">Cells</a></h2> <p>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 <strong>major cell</strong> consists of all the elements that have indices beginning with some particular index <code><span class='Value'>i</span></code>. For this to make sense, <code><span class='Value'>i</span></code> must be between <code><span class='Number'>0</span></code> and the length <code><span class='Value'>l</span></code> of the array's first axis, so that there are <code><span class='Value'>l</span></code> major cells each identified by an index.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MuKAvzPigL80IMOX4oycIDHigL814oC/OOKAvzExCgoxIOKKjyAy4oC/M+KAvzQgw5fijJwgMeKAvzXigL844oC/MTEgICMgTWFqb3IgY2VsbCAx">↗️</a><pre> <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span> <span class='Function'>×</span><span class='Modifier'>⌜</span> <span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>5</span><span class='Ligature'>‿</span><span class='Number'>8</span><span class='Ligature'>‿</span><span class='Number'>11</span> |
