简体   繁体   中英

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?

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 >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM