Julia: [FR] max/maximum min/minimum

Created on 24 Sep 2020  路  5Comments  路  Source: JuliaLang/julia

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.

Most helpful comment

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.

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamed2 picture iamed2  路  3Comments

m-j-w picture m-j-w  路  3Comments

omus picture omus  路  3Comments

dpsanders picture dpsanders  路  3Comments

Keno picture Keno  路  3Comments