I have used the following expression to retrieve the index of the smallest number in a vector. However, I would like to avoid the use of .indexOf
(for efficiency reasons and maybe numeric precision, although I guess the numbers are implicitly converted to strings).
(.indexOf [1 2 3 4 0 5]
(reduce #(if (< %1 %2) %1 %2) [1 2 3 4 0 5] ))
Would it be possible to do it differently using reduce?
user=> (first (apply min-key second (map-indexed vector [1 2 4 0 5]))) 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With