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/windows.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'docs/doc/windows.html') diff --git a/docs/doc/windows.html b/docs/doc/windows.html index bc2aa263..77c40f19 100644 --- a/docs/doc/windows.html +++ b/docs/doc/windows.html @@ -4,10 +4,10 @@ BQN: Windows -

Windows

+

Windows

In BQN, it's strongly preferred to use functions, and not modifiers, for array manipulation. Functions are simpler as they have fewer moving parts. They are more concrete, since the array results can always be viewed right away. They are easier to implement with reasonable performance as well, since there is no need to recognize many possible function operands as special cases.

The Window function replaces APL's Windowed Reduction, J's more general Infix operator, and Dyalog's Stencil, which is adapted from one case of J's Cut operator.

-

Definition

+

Definition

We'll start with the one-axis case. Here Window's left argument is a number between 0 and 1+≠𝕩. The result is composed of slices of 𝕩 (contiguous sections of major cells) with length 𝕨, starting at each possible index in order.

↗️
    5↕"abcdefg"
 β”Œβ”€       
@@ -24,7 +24,7 @@
 "cdefg"
 

Windows differs from Prefixes and Suffixes in that it doesn't add a layer of nesting (it doesn't enclose each slice). This is possible because the slices have a fixed size.

-

Multiple dimensions

+

Multiple dimensions

The above description applies to a higher-rank right argument. As an example, we'll look at two-row slices of a shape 3β€Ώ4 array. For convenience, we will enclose each slice. Note that slices always have the same rank as the argument array.

↗️
    <βŽ‰2 2↕"0123"∾"abcd"≍"ABCD"
 β”Œβ”€                   
@@ -49,10 +49,10 @@
 

The slices are naturally arranged along multiple dimensions according to their starting index. Once again the equivalence i⊏l↕x ←→ l↑i↓x holds, provided i and l have the same length.

If 𝕨 has length 0, then 𝕩 is not sliced along any dimensions. The only slice that resultsβ€”the entire argumentβ€”is then arranged along an additional zero dimensions. In the end, the result is 𝕩, unchanged.

-

More formally

+

More formally

𝕩 is an array. 𝕨 is a number, or numeric list or unit, with 𝕨≀○≠≒𝕩. The result z has shape π•¨βˆΎΒ¬βŸœπ•¨βŒΎ((≠𝕨)βŠΈβ†‘)≒𝕩, and element iβŠ‘z is π•©βŠ‘Λœ(≠𝕨)(↑+⌾((≠𝕨)βŠΈβ†‘)↓)i.

Using Group we could also write iβŠ‘z ←→ π•©βŠ‘Λœ(π•¨βˆΎβ—‹(β†•βˆ˜β‰ )≒𝕩) +Β΄Β¨βˆ˜βŠ” i.

-

Symmetry

+

Symmetry

Let's look at an earlier example, along with its Transpose (⍉).

↗️
    {βŸ¨π•©,β‰π•©βŸ©}5↕"abcdefg"
 β”Œβ”€                   
@@ -77,7 +77,7 @@
 ↗️
    {((5β€Ώ6Β¬2β€Ώ2)↕𝕩) ≑ 2β€Ώ3⍉(2β€Ώ2↕𝕩)} ↕5β€Ώ6β€Ώ7
 1
 
-

Applications

+

Applications

Windows can be followed up with a reduction on each slice to give a windowed reduction. Here we take running sums of 3 values.

↗️
    +˝˘3↕ ⟨2,6,0,1,4,3⟩
 ⟨ 8 7 5 8 ⟩
-- 
cgit v1.2.3