kumi v3.1.0
Exquisite Epidote
 
Loading...
Searching...
No Matches

◆ exclusive_scan_right() [2/2]

template<monoid M, sized_product_type_or_more< 1 > T>
constexpr auto kumi::exclusive_scan_right ( M &&  m,
T &&  t 
)
inlineconstexpr

Computes the exclusive suffix scan of all elements of a product type using a non-tail recursive call.

Note
The first stored value is the identity of the provided monoid.
Parameters
mMonoid callable function to apply
tProduct type to operate on
Returns
A tuple of prefix partial accumulations where each element 'I' equals m( m( m(init, get<0>(t)), ...), get<I-1>(t))

Helper type

namespace kumi::result
{
template<typename Function, product_type Tuple> struct exclusive_scan_right;
template<typename Function, product_type Tuple>
using exclusive_scan_right_t = typename exclusive_scan_right<Function,Tuple>::type;
}
constexpr auto exclusive_scan_right(Function &&f, T &&t, Value init)
Computes the exclusive suffix scan of all elements of a product type using a tail recursive call.
Definition scan.hpp:322

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

Example

#include <kumi/kumi.hpp>
#include <iostream>
int main()
{
auto t = kumi::tuple{2.,1,short{55},'z'};
auto output = kumi::exclusive_scan_right( [](auto elt, auto acc)
{
return acc + sizeof(elt);
}
, t
, std::size_t{42}
);
std::cout << output << "\n";
auto u = kumi::tuple{1,3,2,4,0,5,9,6,7};
}
constexpr numeric_add plus
Forms a binary monoid callable that can be used in kumi::algoritm. It represents the addition.
Definition monoid.hpp:129
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:37