From c7ef3aabb54791b597d4095011ff048c2a13f6ac Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 7 Aug 2021 20:57:51 -0400 Subject: Document use of fill elements for merge of empty --- docs/doc/fill.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs/doc/fill.html') diff --git a/docs/doc/fill.html b/docs/doc/fill.html index 843e80e8..e77872c4 100644 --- a/docs/doc/fill.html +++ b/docs/doc/fill.html @@ -6,7 +6,7 @@

Fill elements

A few array operations need an array element to use when no existing element applies. BQN tries to maintain a "default" element for every array, known as a fill element, for this purpose. If it's known, the fill element is a nested array structure where each atom is either 0 or ' '. If no fill is known, a function that requests it results in an error.

-

Fills are used by Take (โ†‘) when a value in ๐•จ is larger than the corresponding length in ๐•ฉ, by the two Nudge functions (ยปยซ) when ๐•ฉ is non-empty, and by Reshape (โฅŠ) when ๐•จ contains โ†‘. Except for these specific cases, the fill value an array has can't affect the program. The result of Match (โ‰ก) doesn't depend on fills, and any attempt to compute a fill can't cause side effects.

+

Fills are used by Take (โ†‘) when a value in ๐•จ is larger than the corresponding length in ๐•ฉ, by the two Nudge functions (ยปยซ) when ๐•ฉ is non-empty, by Merge (>) when ๐•ฉ is empty, and by Reshape (โฅŠ) when ๐•จ contains โ†‘. Except for these specific cases, the fill value an array has can't affect the program. The result of Match (โ‰ก) doesn't depend on fills, and any attempt to compute a fill can't cause side effects.

Using fills

For the examples in this section we'll use the fact that an all-number array usually has 0 as a fill while a string has ' ' (BQN maintains fills alongside array values rather than deriving them from arrays, so it's possible to construct arrays where this isn't true, but this probably wouldn't happen in ordinary code).

Take (โ†‘) and Nudge (ยปยซ) in either direction use the fill for padding, to extend the array past its boundary. For example, ๐•จโ†‘๐•ฉ will add elements to one side when a number in |๐•จ is larger than the corresponding length in โ‰ข๐•ฉ.

@@ -26,6 +26,7 @@ ยปโŸจโŸฉ # Fill not needed โŸจโŸฉ +

If the argument to Merge is empty then its result will be as well, since the shape โ‰ข๐•ฉ is a prefix of โ‰ข>๐•ฉ. However, the remainder of the result shape is determined by the elements of ๐•ฉ, so if there are none then Merge uses the fill element to decide what the result shape should be.

Reshape (โฅŠ) uses the fill when ๐•จ contains โ†‘ and the product of the rest of ๐•จ doesn't evenly divide the number of elements in ๐•ฉ.

โ†—๏ธ
    โ†‘โ€ฟ8 โฅŠ "completepart"
 โ”Œโ”€          
-- 
cgit v1.2.3