Quick - \ - Cumulative Reduce

Characters: \

Tags: array

Arity: monadic

The resulting link is monadic, meaning it takes one argument. Note that the arity refers to that of the resulting link, not the number of links this quick consumes.


Cumulative reduce or n-wise overlapping (simple) reduce.


If a nilad appears right before \, this does n-wise overlapping reduce. For positive n, split the list into overlapping chunks of length n (identical to (Split (Length, Overlapping))) and reduce each sublist. For negative n, instead of reducing each sublist, slice and remove chunks of length -n. For example, 5R ;-2\ returns [[3, 4, 5], [1, 4, 5], [1, 2, 5], [1, 2, 3]] - in the first list, [1, 2] is removed, in the second list, [2, 3] is removed, etc. Note that it does not cumulatively reduce each slice - if you want to do that, you need to manually slice the list with and cumulatively reduce each sublist.

To a reduce a list, begin with the right argument, and then for each element, apply the link to the current accumulator and the incoming value. a,b,c,... \ is equivalent to [a, a × b, a × b × c, ...]. The link must be a dyad; if you want to apply a monad to the two elements, you can use the idiom ,F¥ for some monad F, which first pairs the elements and then calls F on the result.