访问 ocaml 中的全局引用列表

access a global reference list in ocaml

我有这个代码:


let l = ref []

(*then I have this tail-recurse function 
that is supposed to recalculate with a certain formula 
all the values that are in the global reference list.*)

let f (a:int) (b:int) = 
   (*here I want to put the new values a and b in the 
     l - list and then do my calculations with all the contents 
     in l*)

也许有人可以通过示例向我展示如何做到这一点。

l := a :: b :: !l;
(* Your code here *)

会完成任务的。 l := foofoo 作为新值分配给 l!l 访问存储在 l

中的值