Does F # have anything like Haskell where is the sentence?

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.

+7
source share
3 answers

Unfortunately not - an even sadder order in F # matters. You can use the mutually recursive let rec ... and ... , but it's just not the same as where.

+6
source

There is no such keyword in F #. The difference in both codes is that in one definition, first, and then in use, and in the second - vice versa.

+1
source

Is the "in" keyword in recent versions of F # similar to the Haskell "where" clause?

0
source

All Articles