Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rec count = function
- | Leaf -> 0
- | Node(tl,n,tr) -> count tl + count tr + 1;;
- let rec countA tree n =
- match tree with
- | Leaf -> n
- | Node(tl,_,tr) -> countA tl (countA tr (n+1));;
- let rec countAC tree n c =
- match tree with
- | Leaf -> c n
- | Node(tl,_,tr) -> countAC tl (n+1) (fun vl -> countAC tr vl c);;
- let rec countC t c =
- match t with
- | Leaf -> c 0
- | Node(tl,n,tr) -> countC tl (fun vl -> countC tr (fun vr -> c(vl+vr+1)));;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement