Add a 2-arg flavor, argmax(f, domain)

With the rename to argmax, and dims now a kwarg, it seems very tempting to me to define a 2-arg flavor, argmax(f, domain).

This would be equivalent to x[argmax(f(x) for x=x)] but argmax(f, x) is just so nice. Here, x could be any iterable and argmax(f, x) would quite literally implement the mathematical definition of argmax. Has this been considered?

4 Likes

Seems like a good idea. Would you be willing to open an issue or make a PR?

Ok I’ve filed an issue to at least get the ball rolling. I will try to make a PR. Naively, it seems like a good first issue (second issue? I think it makes sense for argmax to support generators first). Maybe someone will beat me to it, but I’ll give it a shot.

What is domain here?

The iterable x.