Unlike the +
operation that is binary in a given space of objects, and naturally extended to a n-ary operation via the LaTeX \sum
or reduce(+, collection)
, the maximum and minimum of a set of objects is n-ary by definition. Currently, however, we fight with max
vs. maximum
every day depending on the number of arguments we have in our use cases.
I know this is a breaking suggestion, but I think it would be really helpful if the language had a single operation max(collection)
that is n-ary, and ask users to simply do max((x,y))
if they need the binary particular case. Similar for the min
vs. minimum
battle.
Regardless of the potential breaks, do we still have time to fix this annoyance in a major release? Save those seconds looking up the docs every time we need to compute the maximum/minimum of something.
Cf. #11872 and #4652 (which refers to discussion in #4235),
Another option would be to ditch maximum
or minimum
altogether in favor of reduce(max/min, collection)
Right, what's useful about 2-argument max
is that it can be plugged in to reduce
. There are many implementations of reduce, e.g. threaded, distributed, n-dimensional, etc. If max
is in charge of iterating over the collection then conceptually max
has to re-implement all of that. Of course, in practice you would define max2(x,y) = max((x,y))
, but that's the indication to me that this is the wrong factoring of the functionality.
Closing the issue based on the up and down votes 馃憤
Ref #37944
Most helpful comment
Right, what's useful about 2-argument
max
is that it can be plugged in toreduce
. There are many implementations of reduce, e.g. threaded, distributed, n-dimensional, etc. Ifmax
is in charge of iterating over the collection then conceptuallymax
has to re-implement all of that. Of course, in practice you would definemax2(x,y) = max((x,y))
, but that's the indication to me that this is the wrong factoring of the functionality.