Map as a global variable in Ocaml -


i have question manipulating map global variable. in beginning of file, have:

module intord = struct type t = int let compare = ( - ) end module intmap = map.make( intord ) 

then want declare global variable let variables = intmap.empty, variables modified in functions in file. instance, in function let analyze (p: s_program) : unit = want fill in variables values in p. don't see how it, because seems not modify variables anymore; intmap.add : key -> 'a -> 'a t -> 'a t not work either because not change directly values.

do have make global variable reference?

could help? thank much

well, kind of answered own question :). want variable. ocaml functional, let x = ... not declare variable (it's constant binding); variable need make reference. , indeed can modify in functions in:

variables := intmap.add foo bar !variables 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -