42 lines
795 B
Java
42 lines
795 B
Java
import java.lang.Integer;
|
|
|
|
class Y {
|
|
y;
|
|
//factorial;
|
|
|
|
Y() {
|
|
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
|
//factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
|
}
|
|
/*
|
|
getY() {
|
|
return y;
|
|
}
|
|
*/
|
|
}
|
|
/*
|
|
class fac1 {
|
|
factorial;
|
|
|
|
fac1() {
|
|
var y;
|
|
y = new Y<Integer,Integer,Integer,Integer,Integer>().getY();
|
|
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
|
}
|
|
}
|
|
|
|
ergibt Parse-Error
|
|
class fac1 {
|
|
factorial;
|
|
|
|
fac1() {
|
|
var y;
|
|
y = new Y<>().y;
|
|
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
|
}
|
|
public static void main(String args[]) {
|
|
System.out.println(new fac1().factorial.apply(3));
|
|
}
|
|
|
|
}
|
|
*/ |