Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type 'a tree = Br of 'a * 'a tree * 'a tree | Lf
- let rec cata map_lf map_br t =
- match t with
- | Lf -> map_lf ()
- | Br (x, l, r) ->
- let reduced = cata map_lf map_br (Br (x, l, r)) in
- map_br reduced
- let fold_right op tree init = cata
- (fun unit -> init)
- (fun value -> op value)
- tree
- let size t = fold_right (fun x -> 1 + x) t 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement