几个版本的Y组合子

C#版

static Func<T, TResult> Fix<T, TResult>(Func<Func<T, TResult>, Func<T, TResult>> f)
{
    return x => f(Fix(f))(x);
}

static Func<T1, T2, TResult> Fix<T1, T2, TResult>(Func<Func<T1, T2, TResult>, Func<T1, T2, TResult>> f)
{
    return (x, y) => f(Fix(f))(x, y);
}

JavaScript版

var Y = function (F) {
 return (function (x) {
  return F(function (y) { return (x(x))(y);});
  })
		(function (x) {
  return F(function (y) { return (x(x))(y);});
  }) ;
} ;

关于 小寒

这人很懒。
此条目发表在 C#, JavaScript 分类目录,贴了 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>