Core currently only offers a~maximum reduction on
a~vector. \todo{Add a~minimum reduction.} \ref{_maxreduce_}
provides a convenient template-based abstraction.
\ref{maxreduce} is the~function encapsulated by the template and
may be applied directly.
\todo{This function was originally written before TAME supported
let~expressions and other convenience templates. It has since
been refactored slightly, but can be made to be more concise.}
\ref{_maxreduce} is a~helper function that recursively determines
the maximum value of the given set. It should not be invoked
directly; use \ref{maxreduce} or~\ref{_maxreduce_} instead.
For example, given the vector~\vector{2,4,3,1}, here's the
recursive application:
\begingroup
\def\max{\textrm{max}}
\begin{equation}
\max( 1, \max( 3, max( 4, 2 ) ) )
\\ \yield \max( 1, \max( 3, 4 ) )
\\ \yield \max( 1, 4 )
\\ \yield 4
\end{equation}
\endgroup
\todo{If we eventually support first-class functions, then this
can simply be a~generic reduce function that accepts max/min/etc.}
\todo{This function was written before local variables generated
their own unique symbols; strip the prefixes.}
_