Files
comp3958/lectures/07/counter.ml
T

8 lines
147 B
OCaml

let counter =
let c = ref 0 in
(fun () -> incr c; !c);;
let make_counter init =
let c = ref init in
(fun () -> let x = !c in incr c; x);;