Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
DenisYaroshevskiy opened this issue Jul 2, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@DenisYaroshevskiy
Copy link

DenisYaroshevskiy commented Jul 2, 2023

  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

@DenisYaroshevskiy DenisYaroshevskiy added the enhancement New feature or request label Jul 2, 2023
@jfalcou
Copy link
Owner

jfalcou commented Aug 20, 2023

Recent code in kyosu showed we do need that.

sampl implem

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

@jfalcou
Copy link
Owner

jfalcou commented Aug 22, 2023

@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
Copy link
Owner

jfalcou commented Aug 22, 2023

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

@DenisYaroshevskiy
Copy link
Author

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

@jfalcou
Copy link
Owner

jfalcou commented Aug 22, 2023

nvm i am stupid

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants