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

后端 未结 8 627
-上瘾入骨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:28

    break and continue would be a really useful feature additions; they're reserved words, and maybe we'll see them in a future version of the language. The lack of them is an occasional minor annoyance, but hardly makes the language 'unsuitable'. In the mean time, a mutable sentinel works, as you have in your example.

    See also

    http://tomasp.net/blog/imperative-ii-break.aspx/

提交回复
热议问题