我的tree定义类型如下
type 'a tree = Leaf of 'a | Node of 'a * 'a tree * 'a tree ;;
Run Code Online (Sandbox Code Playgroud)
我有一个函数来查找树的深度如下
let rec depth = function
| Leaf x -> 0
| Node(_,left,right) -> 1 + (max (depth left) (depth right))
;;
Run Code Online (Sandbox Code Playgroud)
这个函数不是尾递归的.有没有办法让我以尾递归的方式编写这个函数?