F#有什么像Haskell的where子句吗?

dev*_*ium 7 .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 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)
Run Code Online (Sandbox Code Playgroud)

进入(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)
Run Code Online (Sandbox Code Playgroud)

因为它首先显示了函数的核心部分,后来又显示了实现细节(我猜错了!).

我的猜测是,F#解析代码文件的方式是不可能的.我对吗?看看F#的关键词参考似乎没有像我正在寻找的那样展示.如果它不存在,有没有其他方法可以更好地分解显示的代码?我会说它没关系,但你永远都不会知道......

Car*_*ten 7

可悲的是没有 - 更令人遗憾的是,F#的订单很重要.你可以使用相互递归,let rec ... and ...但它与其他地方不一样.