diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-09-23 16:53:07 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-09-23 16:53:07 -0400 |
| commit | a1e3b94d0539aed459ade2b262e9dd197dd6342c (patch) | |
| tree | 455b7a2f4b038597fc5a1d6d2c28b483dce8a4fa /doc/windows.md | |
| parent | a24bdadc6284c89f592a68c29fcb527eaa8cfc3a (diff) | |
Shift functions are better for fixed-length 2-wise reduction
Diffstat (limited to 'doc/windows.md')
| -rw-r--r-- | doc/windows.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/windows.md b/doc/windows.md index c46bbfcb..30cb344a 100644 --- a/doc/windows.md +++ b/doc/windows.md @@ -65,11 +65,11 @@ Windows can be followed up with a reduction on each slice to give a windowed red +´˘3↕ ⟨2,6,0,1,4,3⟩ -A common task is to pair elements, with an initial or final element so the total length stays the same. This can also be done with a pairwise reduction, but another good way (and more performant without special support in the interpreter) is to add the element and then use windows matching the original length. Here both methods are used to invert `` +` ``, which requires we take pairwise differences starting at initial value 0. +A common task is to act on windows with an initial or final element so the total length stays the same. When using windows of length 2, the best way to accomplish this is with [shift functions](shift.md) like `«` or `»`. If the window length is longer or variable, then a trick with Windows works better: add the elements, and then use windows matching the original length. Here we invert `` +` ``, which requires we take pairwise differences starting at initial value 0. - -˜´˘2↕0∾ +` 3‿2‿1‿1 + -⟜(0»⊢) +` 3‿2‿1‿1 (-˜˝≠↕0∾⊢) +` 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. +With Windows, we can modify the 3-element running sum above to keep the length constant by starting with two zeros. (+˝≠↕(2⥊0)⊸∾) ⟨2,6,0,1,4,3⟩ |
