Daniel Holle
ce4347dd96
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 5m20s
22 lines
482 B
Java
22 lines
482 B
Java
import java.lang.Integer;
|
|
|
|
public class Y {
|
|
y;
|
|
public Y() {
|
|
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
|
}
|
|
}
|
|
|
|
public class Fac1 {
|
|
public factorial;
|
|
public Fac1() {
|
|
var y;
|
|
var tmp = new Y<>(); // TODO Having new Y<>().y on one line doesn't work, see FIXME in StatementGenerator
|
|
y = tmp.y;
|
|
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
|
}
|
|
|
|
public fac(v) {
|
|
return factorial.apply(v);
|
|
}
|
|
} |