I have an array A=[3, 5, 1, 2, 7, 9, 10, 2, 3] length length(A)=9 and a set S that contains a subset of 1:9 indices, for example, S=Set([1, 3, 6, 8]) . I would like to find the maximum (value and index) of A over S That is a maximum of 9 , and an index of 6 .
I tried to do it this way
A = [3, 5, 1, 2, 7, 9, 10, 2, 3]; S = Set([1, 3, 6, 8]); B = [if i in SA[i] else 0 end for i in 1:length(A)]; findmax(B);
but I feel that there is a better and clever way.
source share