From 229e2cd2f5c78b13c483a8559dead2c8f31d8e42 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 18 Jul 2020 18:26:52 -0400 Subject: Terminology changes: subject, 1/2-modifier, Box/Unbox to Enclose/Merge, blocks --- docs/doc/windows.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'docs/doc/windows.html') diff --git a/docs/doc/windows.html b/docs/doc/windows.html index 117acc08..27b9be00 100644 --- a/docs/doc/windows.html +++ b/docs/doc/windows.html @@ -1,6 +1,6 @@

Windows

-

In BQN, it's strongly preferred to use functions, and not operators (modifiers and compositions), 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.

+

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

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.

@@ -18,10 +18,10 @@ 5↑2↓"abcdefg" [ cdefg ] -

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

+

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

-

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 box each slice. Note that slices always have the same rank as the argument array.

-
    <βŽ‰2 2↕"0123"∾"abcd"≍"ABCD"
+

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"
 β”Œ
   β”Œ        β”Œ
     0123     abcd
@@ -30,7 +30,7 @@
                     β”˜
 

Passing a list as the left argument to Windows takes slices along any number of leading axes. Here are all the shape 2β€Ώ2 slices:

-
    <βŽ‰2 2β€Ώ2↕"0123"∾"abcd"≍"ABCD"
+
    <βŽ‰2 2β€Ώ2↕"0123"∾"abcd"≍"ABCD"
 β”Œ
   β”Œ      β”Œ      β”Œ
     01     12     23
@@ -45,8 +45,8 @@
 

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 the left argument has length 0, then the argument 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 the same as the argument.

More formally

-

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

-

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

+

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

+

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

Symmetry

Let's look at an earlier example, along with its transpose.

    {βŸ¨π•©,β‰π•©βŸ©}5↕"abcdefg"
@@ -61,7 +61,7 @@
                     β”˜
 

Although the two arrays have different shapes, they are identical where they overlap.

-
    ≑○(3β€Ώ3βŠΈβ†‘)βŸœβ‰5↕"abcdefg"
+
    ≑○(3β€Ώ3βŠΈβ†‘)βŸœβ‰5↕"abcdefg"
 1
 

In other words, the i'th element of slice j is the same as the j'th element of slice i: it is the i+j'th element of the argument. So transposing still gives a possible result of Windows, but with a different slice length.

@@ -84,7 +84,7 @@ [ 3 2 1 1 ]

This method extends to any number of initial elements. We can modify the running sum above to keep the length constant by starting with two zeros.

-
    ((+Β΄<˘)≠↕(2β₯Š0)⊸∾) ⟨2,6,0,1,4,3⟩
+
    ((+Β΄<˘)≠↕(2β₯Š0)⊸∾) ⟨2,6,0,1,4,3⟩
 [ 2 8 8 7 5 8 ]
 
-- cgit v1.2.3