Pattern matching with guards vs if/else construct in F#

前端 未结 4 831
予麋鹿
予麋鹿 2021-01-12 08:24

In ML-family languages, people tend to prefer pattern matching to if/else construct. In F#, using guards within pattern matching could easily replace if/e

4条回答
  •  清歌不尽
    2021-01-12 09:07

    I did some testing on a self writen prime number generator, and as far as i can say there is "if then else" is significantly slower than pattern matching, can't explain why though, but I as far as I have tested the imperativ part of F# have a slower run time than recursive functional style when it come to optimal algorithms.

提交回复
热议问题