You can also pass the function to argmax, to avoid the allocation of the intermediate array:
julia> x = [1,3,2]
3-element Vector{Int64}:
1
3
2
julia> argmax(x -> -x^2, x)
1
julia> argmax(x -> x^2, x)
3
You can also pass the function to argmax, to avoid the allocation of the intermediate array:
julia> x = [1,3,2]
3-element Vector{Int64}:
1
3
2
julia> argmax(x -> -x^2, x)
1
julia> argmax(x -> x^2, x)
3