I am struggling to write a function where it takes a Sequence, say Hand= {C2; H8; DK; S1} and finds the the lowest integer outcome by 1st removing an element, then using a function I have named CalculateScore() to find the score of that new Sequence.
It does this for all elements in the Sequence but only removes that 1 element, not the ones before it, so 1st run it will remove C2 and calculate score, then it will remove H8(not removing C2) and calculate score. Once it has calculated all scores it then needs to find the one with the lowest value and return that element.
Here is a very brute force non-F# pseudo code example of what I am referring to:
Hand= {C2; H8; DK; S1}, i = 0
NewHand = Hand[i].remove
Score = CalculateScore(newHand)
elementIndex = i
i++
NewHand = Hand[i].remove
if Score > CalculateScore(NewHand)
then Score = NewHand, elementIndex = i
i++
.........
return elementIndex
I have not been doing F# for very long and I am not very good at creating high order functions and stuff like that which is why I am struggling.
Seq.minBy- John Palmer