【发布时间】:2012-04-30 15:26:26
【问题描述】:
今天我们学习了 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;
我正在使用 ocaml,这非常相似,但我只是在做同样的事情时遇到了麻烦。我发现最接近的是
let tempFunc {contents =x}=x;;
但我真的不明白这一点,以及如何将 tempFunc 绑定到另一个函数。任何帮助表示赞赏!
【问题讨论】:
标签: function reference ocaml sml