Guest User

Untitled

a guest
Aug 23rd, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. type values=[
  2. | `Int of int
  3. | `Sym of string
  4. ]
  5. type rvalues=[
  6. values
  7. | `PairVal of values * values
  8. ]
  9. type arrays=[
  10. `ConcArray of values array
  11. | `SymArray of string * int
  12. ]
  13. type rarrays=[
  14. arrays
  15. | `PairArray of arrays * arrays
  16. ]
  17. type side= Left | Right
  18.  
  19. type codmem=
  20. [ rvalues
  21. | rarrays
  22. ]
  23. type mem=(string, codmem) Hashtbl.t
  24.  
  25. let proj_mem (m:mem) s=
  26. let proj:mem=Hashtbl.create (Hashtbl.length m) in
  27. let _=Hashtbl.iter (fun a->fun b->
  28. match b with
  29. | `Int(_) | `Sym(_) -> Hashtbl.add proj a b;
  30. | `PairVal(v1, v2) -> if s=Left then ((Hashtbl.add proj a v1);) else Hashtbl.add proj a v2;
  31. | `ConcArray(_) | `SymArray(_, _) -> Hashtbl.add proj a b;
  32. | `PairArray(v1,v2) -> if s=Left then ((Hashtbl.add proj a v1);) else Hashtbl.add proj a v2;
  33. ) m
  34. in proj
Advertisement
Add Comment
Please, Sign In to add comment