I’m guessing the reduction is with regard to the number of elements, but that is not helpful to a user looking to sum elements. The name “reduce” in this case is how it performs the action, but that exposes implementation in the name and does not focus on what it does. A name is the first and foremost communication to the user as to what it does and not how it does it. Implementation should never be exposed to an interface.
I have used other languages, but C++ is my best known and there it is accumulate for what that’s worth:
template <class InputIterator, class T>
T accumulate (InputIterator first, InputIterator last, T init);
The Wikipedia pages you provided are with regard to parallel processing or recursive processing, which this case has nothing to do with what I’m seeking, so I fail to see the connection. I don’t care about the steps and techniques used to compute a sum more than I care that it computes a sum.
All these arguments (including mine) are not helpful since Kotlin isn’t another language. If you want to argue a Java programmer would expect the name reduce, there is some weight to that argument since Kotlin and Java are closely associated languages. If you want to make this argument, then why does Kotlin not use the keyword “switch” instead of “when”? The word “when” in English is about “time” and Kotlin’s “when” is not run on a interrupt nor is it temporal in any way. So in this case Kotlin used a different name and it is worse.
The only argument one should make on the name of a function is - is it clear to common use cases. My argument is and has been, adding together objects that are not numbers (vectors, UDTs) is a common use case. These docs are poor in two ways.
First, the name isn’t clear. An opinion I should think others share, but an opinion none the less.
Second, and most importantly, the docs have a long list of function signatures before describing what the function does and when it finally does, the docs say, and I quote
" Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element."
So I ask you, if the name reduce is clear, then why is “accumulate” the first thing in the description when you finally scroll past the signatures? When the description of a function uses a word to describe it, it seems that word better describes what it does.
Regardless of all of this, the docs should not first have a long list of function signatures before telling the reader what the function does.
This reply make me dislike Kotlin more because it makes me think the engineers at Kotlin don’t care about their users. I sincerely hope you are wrong, but I suspect you are right.