From 2afb23928e1984d475cc460e1672e8f6fa0e4dbe Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 11 Aug 2021 17:21:31 -0400 Subject: Allow clicking on header to get fragment link --- docs/doc/fill.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/doc/fill.html') diff --git a/docs/doc/fill.html b/docs/doc/fill.html index b4ac35ef..e350fa6e 100644 --- a/docs/doc/fill.html +++ b/docs/doc/fill.html @@ -4,10 +4,10 @@ BQN: Fill elements -

Fill elements

+

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, 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

+

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 𝕩.

↗️
    ¯7  43     # Fill with 0
@@ -38,7 +38,7 @@
 ↗️
    ⊑»1↑⥊"string"
 ' '
 
-

How fills are computed

+

How fills are computed

For the exact requirements placed on fill, see the specification (particularly "required functions"). This section loosely describes behavior in existing BQN implementations, and includes some parts that aren't required in the specification.

A fill element should encompass something that's necessarily true for all elements of an array. If the way an array is computed implies it's all numbers, the fill should be 0. If every element is a list of two numbers, then the fill should be 0,0. If every element is a list but the lengths might vary, ⟨⟩ is probably a reasonable fill element.

For arithmetic primitives, the fill is found by the rules of pervasion, applying the function to both argument fills. Generally this means it consists of 0, but character arithmetic also allows space fills.

-- cgit v1.2.3