Mar. 6th, 2008
some lambda in plain java
Mar. 6th, 2008 06:04 pm See what people, I mean,
dtm, can do with our Java::
![[livejournal.com profile]](https://www.dreamwidth.org/img/external/lj-userinfo.gif)
// Look, it's an anonymous recursive function!
public void testY() {
assertEquals(720,
new Function<Function<Fii, Fii>, Fii>() {
public Fii apply(final Function<Fii, Fii> f) {
return new Branch() {
public Fii apply(final Branch x) {
return f.apply(new Fii() {
public Integer apply(Integer y) {
return x.apply(x).apply(y);
}
});
}
}.apply(new Branch() {
public Fii apply(final Branch x) {
return f.apply(new Fii() {
public Integer apply(Integer y) {
return x.apply(x).apply(y);
}
});
}
});
}
}.apply(new Function<Fii, Fii>() {
public Fii apply(final Fii f) {
return new Fii() {
public Integer apply(Integer i) {
return (i <= 0) ? 1 : i * f.apply(i - 1);
}
};
}
}).apply(6).intValue());
}
}