Is my rec function tail recursive?

后端 未结 3 1243
既然无缘
既然无缘 2021-01-21 02:04


Is this function tail-recursive ?

let rec rec_algo1 step J = 
    if step = dSs then J
    else
        let a = Array.init (Array2D.length1 M) (fun i ->         


        
3条回答
  •  星月不相逢
    2021-01-21 02:46

    This function is tail-recursive; I can tell by eyeballing it.

    In general it is not always easy to tell. Perhaps the most reliable/pragmatic thing is just to check it on a large input (and make sure you are compiling in 'Release' mode, as 'Debug' mode turns off tail calls for better debugging).

提交回复
热议问题