jfalcou / kumi

C++20 Compact Tuple Tools
https://jfalcou.github.io/kumi/
Boost Software License 1.0
47 stars 7 forks source link

[FEATURE] kumi::fold_left/kumi::fold_right to have no init versions. kumi::reduce #71

Closed DenisYaroshevskiy closed 1 year ago

DenisYaroshevskiy commented 1 year ago
  1. Was looking for kumi::reduce. There was none. Took some time to figure it's fold_left/fold_right.
  2. They require init. I don't have one. You don't need init if you tuple is not empty - let's have no init overloads.

Also balanced reduction can be awfully nice! (fold_balanced?) Smth like: https://github.com/jfalcou/eve/blob/d75ab0f23e472bfe04f406aeb5b7e0e90671a574/include/eve/module/algo/algo/array_utils.hpp#L54-L58

jfalcou commented 1 year ago

Recent code in kyosu showed we do need that.

sampl implem

return kumi::sum( kumi::extract(t,kumi::index<1>), get<0>(t));
jfalcou commented 1 year ago

@DenisYaroshevskiy I think no init fold means the operation you do on your values are limited cause the 1st value never got passed to any function, right ?

For the balanced one, it can be fold and it is a great idea

jfalcou commented 1 year ago

Meanwhile, I'll push a PR that no-init all the named reduction

DenisYaroshevskiy commented 1 year ago

Why isn't it past? Fold takes a 2 argument op

jfalcou commented 1 year ago

nvm i am stupid