多くの関数型言語で見られる固定小数点ジェネレーターを C# で定義しようとしました。私は、foldr は通常、固定小数点ジェネレーターの観点から定義されると考えています。Haskell の定義と、C# での定義を示します。どんな助けでも大歓迎です。
//Haskell
fix f = f (fix f)
//C# (Many attempts)
public static Func<Func<T, T>, T> Combinator1<T>(this Func<T, T> f)
{
return x => f(Combinator1(f)(x));
}
public static Func<Func<T, T>, T> Combinator2<T>(this Func<T, T> f)
{
return x => x(Combinator2(x)(f));
}
public static Func<T, U> Combinator3<T, U>(Func<Func<T, U>, Func<T, U>> f)
{
return f(x => Combinator3(f)(x));
}