What's the reason of marking a recursive function as rec in F#?

后端 未结 5 1105
长情又很酷
长情又很酷 2020-12-31 04:04

I am not sure if this is a stupid question but I was going through the tutorial that comes with VS 2010 and there is a function like this:

let rec factorial          


        
5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 04:28

    According to Chris Smith (works on the F# team) -

    It's to inform the type inference system to allow the function to be used as part of the type inference process. rec allows you to call the function before the type inference system has determined the function's type

提交回复
热议问题