2770
2014-09-08 23:24:18
0
package fn.test;
@FunctionalInterface
interface IFunc<T> {
abstract T apply(T p);
}
@FunctionalInterface
interface ICompose<T> {
abstract T compose(IFunc<T> fst, IFunc<T> scd, T p);
}
public class TestRun {
public static void main(String[] args) {
IFunc<Integer> plus = (p) -> {
return p + 1;
};
IFunc<Integer> square = (n) -> {
return n * n;
};
ICompose<Integer> compose = (fst, scd, n) -> {
return scd.apply(fst.apply(n));
};
System.out.println(compose.compose(plus, square, 2));
}
}