RosettaCodeData/Task/Pointers-and-references/Standard-ML/pointers-and-references.ml

4 lines
216 B
OCaml

val p = ref 1; (* create a new "reference" data structure with initial value 1 *)
val k = !p; (* "dereference" the reference, returning the value inside *)
p := k + 1; (* set the value inside to a new value *)