I have a vector of Tuple
s v
for which I want to find the maximum based on, say, the first element of the Tuple
.
sort
has the by
keyword: to sort the vector I would do sort(v; by=x->x[1])
. What is the equivalent way for maximum
?
I have a vector of Tuple
s v
for which I want to find the maximum based on, say, the first element of the Tuple
.
sort
has the by
keyword: to sort the vector I would do sort(v; by=x->x[1])
. What is the equivalent way for maximum
?
I think you might want argmax(f, A)
which returns the value x
in A
for which f(x)
is maximized. So in your case this could be maxtuple = argmax(first, v)
.