巻末の階乗計算Yコンビネータ for the loyal Schemers and MLers:)。mainを付けて動くようにはしたけど、完全には理解できず。

package littlejava;

public class LittleJavaFactorial {
  public static void main(String[] args) {
    O_O factorial = new Y().apply(new MkFact());
    System.out.println(factorial.apply(new Integer(3)));
  }
}

interface T {
  O_O apply(T x);
}
interface O_O {
  Object apply(Object y);
}
interface OO_OO {
  O_O apply(O_O fact);
}
interface OO_OO_OO {
  O_O apply(OO_OO f);
}

class Y implements OO_OO_OO {
  public O_O apply(OO_OO f) {
    return new H(f).apply(new H(f));
  }
}
class H implements T {
  private final OO_OO f;
  H(OO_OO f) {
    this.f = f;
  }
  public O_O apply(T x) {
    return f.apply(new G(x));
  }
}
class G implements O_O {
  private final T x;
  G(T x) {
    this.x = x;
  }
  public Object apply(Object y) {
    return (x.apply(x)).apply(y);
  }
}

class MkFact implements OO_OO {
  public O_O apply(O_O fact) {
    return new Fact(fact);
  }
}
class Fact implements O_O {
  private final O_O fact;
  Fact(O_O fact) {
    this.fact = fact;
  }
  public Object apply(Object y) {
    int inti = ((Integer)y).intValue();
    if (inti == 0) {
      return new Integer(1);
    } else {
      return 
        new Integer(
          inti
          * 
          ((Integer)fact.apply(
                new Integer(inti - 1))).intValue()
              );
    }
  }
}