I have a sequence and I need to find both the minimum value of the sequence, and that value’s index in the sequence – effectively some sort of “Seq.mini” function along the lines of Seq.mapi or Seq.iteri.
What’s the cleanest / most idiomatic way of expressing this in F#?
Idiomatically, should I be expecting to write a function that returns a tuple (value, index) or (index, value) and if so is there a convention for which order these values should appear?
One other thing: If there is more than one element with the same minimum value, I need the index of the first occurrence – I guess this translates into a strictly “less than (<)” comparison rather than “less than or equal to (<=)” – correct?
This is a simple clean solution: