compress versus fold
- Lingua principale
- C++
- Stelle
- 509
- Fork
- 94
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
There are two variants of fold, left associative versus right.
What about naming them `fold_left` and `fold_right`?
Given an adaptor that results in a variadic function as `compress`
compress:: F A -> (B.... -> A)
we could define it by using a function having a tuple as parameter
```
compress(f, z)(xs...) = fold(f, z, forward_as_tuple(xs...))
```
I believe that we have already this kind of fold fuctions in Hana.
So given
```
fold: F A H -> A
```
`partial(fold, F, A)` would almost behave like compress except that `partial(fold, F A)` takes a tuple as parameter and compress takes a variadic number of arguments. So we can see compress something like
```
compress(f, a) = compose(partial(fold, f, a), forward_as_tuple)
```
I'm not saying that compress is not useful, even if the name has not too much relation to what is behind the scenes. I would say that it could be a useful shortcut when the user doesn't has already a sequence or a tuple.
Of course, in C++ we don't want to pay more than needed, so the implementation should be more efficient than using the right hand side.
It would be fanny to have some performance measures. This is micro-benchmarking, but having the figures would help the user to understand the trade-offs.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.