Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rec countA (a:int) = function
- | Leaf -> 0
- | Node(tl,n,tr) -> countA a tl + countA a tr + (a+1)
- let rec countAC t (a:int) c =
- match t with
- | Leaf -> c 0
- | Node(tl,n,tr) -> countAC tl a (fun vl -> countAC tr a (fun vr -> c(a+vl+vr+1)))
- let rec count = function
- | Leaf -> 0
- | Node(tl,n,tr) -> count tl + count tr + 1
- 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