今天我们在SML中学到了"打结",你有类似的东西
val tempFunc = ref (fn k:int => true);
fun even x = if x = 0 then true else !tempFunc(x-1);
fun odd x = if x = 0 then false else even(x-1);
tempFunc := odd;
Run Code Online (Sandbox Code Playgroud)
而我正在使用类似的ocaml,但我只是在做同样的事情.我发现的最接近的是
let tempFunc {contents =x}=x;;
Run Code Online (Sandbox Code Playgroud)
但我真的不明白,以及如何将tempFunc绑定到另一个函数.任何帮助表示赞赏!