Reputation: 1
I want to make a function in which the parameter is mutable.
I'm familiar with let a = ref 0
but how can i make "a" be a parameter for my function?
Upvotes: 0
Views: 120
Reputation: 18892
If you ask Ocaml nicely, it will infer the right type for you:
let incr x = x:= !x + 1
val incr : int ref -> unit = < fun >
Upvotes: 5