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

后端 未结 5 1149
长情又很酷
长情又很酷 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:37

    It's necessary so that the function can be recursive. A non-rec function only knows about bindings at the place where it's defined, not after (so it doesn't know about itself).

提交回复
热议问题