I'd like to make applyAndTruncate
hidden from the outside world (that is, from anything outside the Scoring
module), as I really only use it as backbone for bestKPercent
and worstKPercent
. Is it possible to hide it? If not, what is the F#ish way of accomplishing what I want to do?
module Scoring
let applyAndTruncate f percentage (scoredPopulation:ScoredPopulation) : ScoredPopulation =
if (percentage < 0.0 || percentage > 1.0) then
failwith "percentage must be a number between 0.0 and 1.0"
let k = (int)(percentage * (double)(Array.length scoredPopulation))
scoredPopulation
|> f
|> Seq.truncate k
|> Seq.toArray
let bestKPercent = applyAndTruncate sortByScoreDesc
let worstKPercent = applyAndTruncate sortByScoreAsc