cpp/experimental/reduce

@1@ same as @3@ same as @5@ Reduces the range $[first; last)$, possibly permuted and aggregated in unspecified manner, along with the initial value over. @2,4,6@ Same as, but executed according to

The behavior is non-deterministic if is not associative or not commutative.

The behavior is undefined if modifies any element or invalidates any iterator in $[first; last)$.

Return value
Generalized sum of and, , ... over ,

where generalized sum $GSUM(op, a 1, ..., a N)$ is defined as follows:
 * if $N=1$, $a 1$
 * if $N > 1$, $op(GSUM(op, b 1, ..., b K), GSUM(op, b M, ..., b N))$ where
 * $b 1, ..., b N$ may be any permutation of $a1, ..., aN$ and

in other words, the elements of the range may be grouped and rearranged in arbitrary order

Complexity
$1 < K+1 = M ≤ N$ applications of.