我需要在Ocaml中使用可变变量的哈希表,但它没有用.
let link = Hashtbl.create 3;;
let a = ref [1;2];;
let b = ref [3;4];;
Hashtbl.add link a b;;
# Hashtbl.mem link a;;
- : bool = true
# a := 5::!a;;
- : unit = ()
# Hashtbl.mem link a;;
- : bool = false
Run Code Online (Sandbox Code Playgroud)
有没有办法让它有效?
如何在OCaml中定义树+指向其子树的指针,以便在此子树中添加叶子需要恒定的时间?