我有这个代码:
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 := foo
将foo
作为新值分配给l
,!l
访问存储在l
中的值