Advertisement
Guest User

Untitled

a guest
Nov 30th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.40 KB | None | 0 0
  1. type 'a tree =  | Lf
  2.                | Br of 'a * 'a tree * 'a tree
  3. let rec f(n,t) =
  4.     match t with
  5.     | Lf -> Lf
  6.     | Br(a,t1,t2) -> if n>0 then Br(a, f(n-1, t1), f((n-1), t2))
  7.                             else Lf
  8. let rec g p = function
  9.     | Br(a, t1, t2) when p a -> Br(a, g p t1, g p t2)
  10.     | _ -> Lf;;
  11. let rec h k = function
  12.     | Lf -> Lf
  13.     | Br(a, t1, t2) -> Br(k a, h k t1, h k t2);;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement