Wwwardrunaa
Wwwardrunaa

Reputation: 1

How to make the parameter of an Ocaml function be a mutable int?

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

Answers (1)

octachron
octachron

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

Related Questions