racket/collects/honu/examples/Y.honu
Stevie Strickland 7dbb99d3c6 merged 292:296 from branches/sstrickl
svn: r297
2005-07-02 04:03:02 +00:00

16 lines
365 B
Plaintext

int -> int fix(<int -> int> -> int -> int f) {
T -> int -> int g = int->int fun(T x) { f(int fun(int y) { x.f(x)(y); }); };
g (new Y(f = g));
}
struct Y(T -> int -> int f) : T { }
int -> int factorialor(int -> int factorial) {
int fun(int x) {
if(x == 0) { 1; }
else { x * factorial(x - 1); };
};
}
int main(int n) { fix(factorialor)(n); }