aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-07-12 21:43:15 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-07-12 21:43:15 -0400
commitd4cbba4377779d7ce5af0035525883310afa7cc4 (patch)
tree9041bc589980ba65fdc5dab21e6c658604f7226b /doc
parentde0b28520bc7bb65459db17c7451f808f6ef4e3e (diff)
Windows diagram
Diffstat (limited to 'doc')
-rw-r--r--doc/reshape.md1
-rw-r--r--doc/windows.md36
2 files changed, 36 insertions, 1 deletions
diff --git a/doc/reshape.md b/doc/reshape.md
index b4081a53..21d979ee 100644
--- a/doc/reshape.md
+++ b/doc/reshape.md
@@ -21,7 +21,6 @@ Path ← ("path"At⊣) Elt "d"⋈⊢
pad ← 48‿51 ⋄ sh ← 0‿0
dim ← (pad-0‿7) + ¯1⊑¨ tx‿ty ← pad+d× ¯1(⊑{⟨↕𝕨,⥊+⌜´(↕¨×·×`⌾⌽1+«)𝕩⟩}↓)≢xt
tb ← >0‿¯1⊸⊏¨tx‿ty
-cg ← "font-size=19px|text-anchor=middle"
bp ← ⥊⌽(20×1.5‿¯1) (+⌾⊑ ≍ -⊸≍∘⊣)˘ 29‿21-⊸≍⊸+⍉tb
(((-∾+˜)64‿15)+sh∾dim) SVG g Ge ⟨
diff --git a/doc/windows.md b/doc/windows.md
index 6c009143..baae3efc 100644
--- a/doc/windows.md
+++ b/doc/windows.md
@@ -2,6 +2,42 @@
# Windows
+<!--GEN
+zt ← (w←5) ↕ xt ← Highlight∘•Repr¨ ↕8
+d ← 40‿40
+
+Ge ← "g"⊸At⊸Enc
+rc ← At "class=code|stroke-width=1.5|rx=12"
+g ← "fill=currentColor|font-family=BQN,monospace|text-anchor=middle|font-size=18px"
+bg ← "class=bluegreen|stroke-width=3|stroke-linecap=round|style=fill:none|opacity=0.7"
+sg ← "fill=none|stroke-width=1|stroke=currentColor"
+col ← {"class"‿𝕩≍"style"‿"fill:none"}¨"purple"‿"red"‿"yellow"‿"green"
+
+Text ← ("text" Attr "dy"‿"0.33em"∾·Pos d⊸×)⊸Enc
+Rect ← "rect" Elt Pos⊸∾⟜("width"‿"height"≍˘FmtNum)˝{𝕨⊢⊘∾𝔽𝕩}
+Path ← ("path"At⊣) Elt "d"⋈⊢
+
+ay ← ¯2 ⋄ lx ← ¯1.2
+Exp ← (-≍+˜)⊸+
+dim ← 48‿36 Exp d⊸ע lx‿ay ≍ ⟨lx-˜zt-○≠⊏xt,-ay⟩ + ¯1⊑¨ tx‿ty ← ⌽↕¨≢zt
+my ← 2÷˜¯1⊑ty
+
+Pd ← ∾∾¨⟜FmtNum
+l ← 6‿15
+br ← ∾ ((0.6-⊸⋈⊸+0⋈1-˜≠xt)((0‿¯1×l)+d×⋈)¨ay) ("M l l "Pd⥊∘∾)¨ ⋈⟜⌽ -⌾⊑⊸≍l
+bp ← ⥊⌽(20×1.5‿¯1) (+⌾⊑ ≍ -⊸≍∘⊣)˘ 28‿24-⊸≍⊸+ d×⍉>0‿¯1⊸⊏¨tx‿ty
+sl ← (0⋈¨ty)≍ty⋈¨ay+0.05×ty-my
+
+(⥊48‿16 Exp dim) SVG g Ge ⟨
+ rc Rect dim
+ "text-anchor=end" Ge ay‿my lx⊸⋈⊸Text⟜Highlight¨ (⊢⋈(FmtNum w)∾"↕"∾⊢)"𝕩"
+ sg Ge col Rect⟜{d⊸ע¯0.1 Exp (¯0.5+𝕩)≍⟨≠tx,1⟩}¨⎉1 sl
+ bg Path br ∾ "M hv" ∾˜⊸Pd bp
+ ((↕≠xt)⋈⌜ay) Text¨ xt
+ (⍉tx⋈⌜ty) Text¨ zt
+⟩
+-->
+
The Windows function returns all slices, or contiguous subarrays, with shape (well, shape prefix) `𝕨` from `𝕩`. It might also be seen as sliding a moving window along `𝕩`.
This function replaces APL's Windowed Reduction, J's more general Infix operator, and Dyalog APL's Stencil, which is adapted from one case of J's Cut operator. In BQN, it's strongly preferred to use functions, and not modifiers, for array manipulation. Functions are simpler with fewer moving parts, and more concrete, since the array results can always be viewed right away.