Windowed Reduce

From APL Wiki
Revision as of 17:19, 8 February 2021 by Razetime (talk | contribs) (Created Windowed Reduce Page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
/

Windowed Reduce (/, ), also called N-wise Reduce, is a primitive dyadic operator which takes a dyadic function, and a number as its left argument, inserts it between the overlapping "windows" of the size of its left argument, and evaluates it into a single array in right-to-left order.

Description

When applied to a vector argument, n f/x evaluates to the expression (a f b f c)(b f c f d) … where a, b, c, d, … are the elements of x, grouped into windows of size n. It works like Reduce, except applied on overlapping segments of an array, and borrows most of its functionality from it.

Examples

Windowed reduce is used to apply functions on overlapping sections of array e.g. when you need the deltas of an array.

      3+/5 1 4 1 8
10 6 13
      2-/1 2 3 4 5
¯1 ¯1 ¯1 ¯1
      4,/35 56 67 79 91
┌───────────┬───────────┐
│35 56 67 79│56 67 79 91│
└───────────┴───────────┘

External links

Lessons

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector