I was wondering if there is anything in F # like the Haskell where clause. This would convert the following code
let roulleteWheel numberGenerator (scoredPopulation:ScoredPopulation) = let targetScore = let totalScore = totalPopulationFitness scoredPopulation Seq.head (numberGenerator 0.0 totalScore) let isMatch (score, accumulatedScore) = if (accumulatedScore >= targetScore) then Some(score) else None let accumulatedScores = let scores = Seq.map (fun (_, score) -> score) scoredPopulation Seq.skip 1 (Seq.scan (+) 0.0 scores) Seq.pick isMatch (Seq.zip scoredPopulation accumulatedScores)
in (imo) a slightly more readable version
let roulleteWheel numberGenerator (scoredPopulation:ScoredPopulation) = Seq.pick isMatch (Seq.zip scoredPopulation accumulatedScores) where let targetScore = let totalScore = totalPopulationFitness scoredPopulation Seq.head (numberGenerator 0.0 totalScore) let isMatch (score, accumulatedScore) = if (accumulatedScore >= targetScore) then Some(score) else None let accumulatedScores = let scores = Seq.map (fun (_, score) -> score) scoredPopulation Seq.skip 1 (Seq.scan (+) 0.0 scores)
as it shows the main part of the function first and implementation details later (nitpicking, I think!).
My guess is that it would be impossible if F # parses code files. I'm right? Looking at the F # keyword doesn't seem to be like something like what I'm looking for. If this does not exist, is there any other way to better see the code shown? I would say that everything is in order, but you never know.
devoured elysium
source share