.net 有F#类似Haskell';where子句是什么?

.net 有F#类似Haskell';where子句是什么?,.net,f#,functional-programming,.net,F#,Functional Programming,我想知道F#中是否有像Haskell的where子句那样的东西。它将允许转换以下代码 let roulleteWheel numberGenerator (scoredPopulation:ScoredPopulation) = let targetScore = let totalScore = totalPopulationFitness scoredPopulation Seq.head (numberGenerator 0.0 totalScore) let i

我想知道F#中是否有像Haskell的
where
子句那样的东西。它将允许转换以下代码

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)
进入(imo)稍微可读的版本

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)
因为它首先显示了函数的核心部分,然后显示了实现细节(我认为是吹毛求疵!)


我的猜测是,用F#解析代码文件的方式是不可能的。我说得对吗?查看F#的关键字引用似乎并没有显示出我想要的任何东西。如果它不存在,是否有其他方法可以更好地分解显示的代码?我想说这是可以的,但你永远不知道。

可悲的是,不-更可悲的是,F#中的顺序非常重要。
您可以使用相互递归
let rec。。。而且…
但是它和where不一样。

在F#中没有这样的关键字。这两种代码的区别在于,其中一种代码的定义先出现后使用,而第二种代码的定义则相反。

最新版本的F#中的“in”关键字与Haskell的“where”子句类似吗