Guest User

Untitled

a guest
Nov 25th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.46 KB | None | 0 0
  1. module First = struct
  2.  
  3.     let next r = incr r; !r
  4.  
  5. end
  6.  
  7. module Second = struct
  8.  
  9.     let r = ref 0
  10.  
  11.     let next () = incr r; !r
  12.  
  13. end
  14.  
  15.  
  16. module Third = struct
  17.  
  18.  
  19.     module Counter (ANY : sig end) = struct
  20.  
  21.         let r = ref 0
  22.  
  23.         let next () = incr r; !r
  24.  
  25.     end
  26.  
  27.     let create_counter () =
  28.         let module M = Counter(struct end) in
  29.         M.next
  30.  
  31.     let next1 = create_counter ()
  32.  
  33.     let next2 = create_counter ()
  34.  
  35. end
Advertisement
Add Comment
Please, Sign In to add comment