使用 Define 的方案中的 Y 组合器
为了了解定点组合器的含义和用途,我编写了自己的定点组合器。但我没有使用严格的匿名函数来编写它,例如 维基百科的示例,而是使用了定义:
(define combine (lambda (functional)
(functional (lambda args (apply (combine functional) args))))
我已经用阶乘和斐波那契函数对此进行了测试,它似乎有效。这是否满足定点组合器的正式定义?
In order to learn what a fixed-point combinator is and is used for, I wrote my own. But instead of writing it with strictly anonymous functions, like Wikipedia's example, I just used define:
(define combine (lambda (functional)
(functional (lambda args (apply (combine functional) args))))
I've tested this with functionals for factorial and fibonacci, and it seems to work. Does this meet the formal definition of a fixed-point combinator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:虽然 chessweb 或其他任何人证实了他的答案,但暂时认为他的答案是正确的,而这个答案是错误的。
看来答案是肯定的。显然,完全相同的组合器出现在此处,位于页面中间:
EDIT: While chessweb or anyone else corroborates his answer, temporarily consider his answer correct and this one wrong.
It seems the answer is yes. Apparently the exact same combinator appears here, midway down the page:
答案是否定的,因为根据上一个答案中提到的博客,它不甚至满足组合器的定义,因为“组合”是一个自由变量。
The answer is no, because according to the blog referred to in the previous answer, it doesn't even meet the definition of combinator, since 'combine' is a free variable.