KUMI v5.0.0
Gorgeous Garnet
Loading...
Searching...
No Matches
kumi::inclusive_scan_right

Callable object computing the inclusive suffix scan of all elements of a product type using a non-tail recursive call. More...

Variables

constexpr inclusive_scan_right_t kumi::inclusive_scan_right {}

Detailed Description

Callable object computing the inclusive suffix scan of all elements of a product type using a non-tail recursive call.

Variable Documentation

◆ inclusive_scan_right

inclusive_scan_right_t kumi::inclusive_scan_right {}
inlineconstexprnodiscard

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

Note
The first stored value is the result of the application of the function to the provided initial value and the first element of the product_type.

Header file

#include <kumi/kumi.hpp>

Call Signature

namespace kumi
{
template<typename Function, concepts::product_type T, typename Value>
constexpr auto inclusive_scan_right(Function f, T && t, Value init);
template<concepts::monoid M, typename Function, concepts::product_type T, typename Value>
constexpr auto inclusive_scan_right(M && m, T && t);
}
constexpr inclusive_scan_right_t inclusive_scan_right
Definition scan.hpp:351
Main KUMI namespace.
Definition algorithm.hpp:11

Parameters

  • m: Monoid callable function to apply
  • f: Binary callable function to apply
  • t: Product Type to operate on
  • init: Optional initial value of the scan

Return value

  • A tuple of suffix partial accumulations where each element 'I' equals f(get<0>(t), f(... , f(get<N-1>(t), init))

Helper type

template<typename Function, kumi::concepts::product_type T, typename... Value>
requires((sizeof...(Value) == 0) || (sizeof...(Value) == 1))
using inclusive_scan_right_t =
template<typename Function, kumi::concepts::product_type T, typename... Value>
requires((sizeof...(Value) == 0) || (sizeof...(Value) == 1))
struct inclusive_scan_right
{
using type = kumi::result::inclusive_scan_right_t<Function, T, Value...>;
};

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

Examples

  • Tuple
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    auto t = kumi::tuple{2.,1,short{55},'z'};
    auto output = kumi::inclusive_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};
    std::cout << kumi::inclusive_scan_right(kumi::function::plus, u) << "\n";
    }
    Fixed-size collection of heterogeneous values.
    Definition tuple.hpp:35
  • Record
    #include <kumi/kumi.hpp>
    #include <iostream>
    int main()
    {
    using namespace kumi::literals;
    auto r = kumi::record{"a"_id = 2.,"b"_id = 1,"c"_id = short{55},"d"_id = 'z'};
    auto output = kumi::inclusive_scan_right( [](auto elt, auto acc)
    {
    return acc + sizeof(elt);
    }
    , r
    , std::size_t{42}
    );
    std::cout << output << "\n";
    auto u = kumi::record{"a"_id = 1,"b"_id = 3,"c"_id = 2,"d"_id = 4, "e"_id = 0
    , "f"_id = 5,"g"_id = 9,"h"_id = 6,"i"_id = 7};
    std::cout << kumi::inclusive_scan_right(kumi::function::plus, u) << "\n";
    }
    Fixed-size collection of heterogeneous fields with distinct labels.
    Definition record.hpp:36