Why “do…while” does not exist in F#

后端 未结 8 488
-上瘾入骨i
-上瘾入骨i 2021-02-04 00:36

I cannot find \"do...while...\"

I have to code like this:

let bubbleSort a=
    let n = Array.length a
    let mutable swapped = true
    let mutable i =         


        
8条回答
  •  伪装坚强ぢ
    2021-02-04 01:33

    It turns out to be quite easy to write a good enough do-while in F# as a higher-order function:

    let doWhile f c =
        f ()
        while c () do
            f ()
    

提交回复
热议问题