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,  evaluates to the expression  … where ,  ,  ,  , … are the elements of  , grouped into windows of size. It works like Reduce, except applied on overlapping segments of an array, and borrows most of its functionality from it. When is negative, each window is reversed before the reduction is done.

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

Notable uses
Windowed Reduce is especially common with a left argument of 2 or ¯2, as it is then a pair-wise application of the operand between neighbouring elements, and especially so with comparison functions. For example,  indicates the elements that differ from their neighbour on the left. For a Boolean vector, the expression   indicates the first 1 in each contiguous run of 1s.

Lessons

 * APL Cultivation

Documentation

 * Dyalog
 * APLX