关于 Ocaml Refs 的初学者问题
let x = ref 100 in
let f () = !x in
let x = ref 50 in
??? ; f ()
通过将一些东西插入 ??? ,你应该得到 50 的答案。 (不是阴影)。但我现在不知道如何更改原始引用的值,考虑到 x := 50 现在将应用于第二个 x....
let x = ref 100 in
let f () = !x in
let x = ref 50 in
??? ; f ()
You are supposed to get the answer to be 50 by plugging something into the ??? (not shadowing). But I don't know how to change the value of your original ref now, considering x := 50 is going to apply to the SECOND x now....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这确实是一个“初学者问题”,那可能不是预期的答案。但我不知道“预期答案”是什么,所以让我们来解决一下。
相关链接
If it really is a "beginner question", that's probably not the expected answer. But I don't know what the "expected answer" is, so let's hack around instead.
relevant link
现在无法访问原始的
x
。所以..影子f
!There is no way to access original
x
now. So.. shadowf
!