KUMI v4.0.0
Flawless Fluorite
Loading...
Searching...
No Matches

◆ reduce

reduce_t kumi::reduce {}
inlineconstexprnodiscard

Callable object performing a tree-like reduction of all elements of a product type.

On record types, this function operates on the underlying values, not on the fields themselves.

Note
For associative operations, this produces the same result as a left or right fold, but have different intermediate evaluation order.

inline constexpr

Header file

#include <kumi/algorithm/reduce.hpp>

Call Signature

template<monoid M, product_type T>
constexpr auto reduce(M && m, T && t);
constexpr reduce_t reduce
Callable object performing a tree-like reduction of all elements of a product type.
Definition reduce.hpp:236
template<monoid M, product_type T, typename V>
constexpr auto reduce(M && m, T && t, V init);

Parameters

  • m: Monoid callable function to apply
  • t: Product Type to reduce
  • init: Optional initial value of the reduction.

Return value

The result of reducing the elements of `t` by `m`, recursively combining elements in a tree structure.

Helper type

namespace kumi::result
{
template<monoid M, product_type T> struct reduce;
template<monoid M, product_type T>
using reduce_t = typename reduce<M,T>::type;
template<monoid M, product_type T, typename Value> struct reduce;
template<monoid M, product_type T, typename Value>
using reduce_t = typename reduce<M,T,Value>::type;
}

Computes the return type of a call to kumi::reduce

Examples