Guest User

Untitled

a guest
Mar 17th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.49 KB | None | 0 0
  1. open Types ;;
  2. open Tools ;;
  3.  
  4.  
  5. let rec eval2 t = match t with
  6.   | Apply (Lambda(s,tt),t2) when ( (v t2) ) -> sub s t2 tt
  7.   | Apply (t1,t2) when (v t1) -> Apply(t1, eval2 t2)
  8.   | Apply (t1 ,t2) -> Apply(eval2 t1, t2)
  9.   | _ -> t
  10. ;;
  11.  
  12. let rec eval1 t =  
  13.   match eval2 t with
  14.      | tt when ( (v tt) or t = tt ) -> tt
  15.      | tt -> eval1 tt
  16. ;;
  17.  
  18. let eval t =
  19.   match t with
  20.     Let(s,tt) -> let r = (eval1 tt) in alias := StringMap.add s r !alias ; Let(s,r)
  21.     | _ -> eval1 t
  22. ;;
Advertisement
Add Comment
Please, Sign In to add comment